Quantcast
Channel: Active questions tagged visual-studio-code - Stack Overflow
Viewing all articles
Browse latest Browse all 98725

How to Override/replace jsdoc properties?

$
0
0

I'm creating an express route handler and I want to extend the express.Request interface to document what the params and query properties should be. I would like the jsdoc's to work in had with VsCode intellisense.

At first, I import the Request and Response from express.

/**
 * @typedef {import('express').Request} Request
 * @typedef {import('express').Response} Response
 */

I then create 2 types for the params and query.

/**
 * @typedef {{
 *   module: string
 * }} params
 */

/**
 * @typedef {{
 *   field: string
 *   skip: number
 *   limit: number
 * }} query
 */

As a parameter of my function, I extend the express Request and override my query and params.

/**
 * @param {Request & {params: params, query: query}} req
 * @param {Response} res
 */
async function search(req, res)

Here is where my problem arises... I only get intellisense for the params, but not for the query.

Screenshot of req.parmas intellisenseScreenshot of req.params intellisense

Screenshot of req.query intellisenseenter image description here

When I hover my mouse over the req param I get the following intellisense.

req intellisense

Am I using the 'extend' feature correctly? How can I extend the Request type & get intellisense for both query and params?


Viewing all articles
Browse latest Browse all 98725

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>