I believe the previous answer may in fact be a good solution for you.
JSDoc works with intellisense when applied where a method/function/variable is defined rather than where it’s used. Unfortunately, you won’t be able to give intellisense to parameters of app.post (including a callback function) as you have it, because you are invoking app.post rather than defining it.
Since the second argument to app.post is a callback function, and you want to have intellisense inside of it, your best bet is probably to define that function separately (instead of passing it as an anonymous function) so you can give it a JSDoc.
Alternatively, you could look into using typescript which has typed intellisense built in for most commonly used packages.
2
Answers
Could something like this be what you’re looking for? I think you may want to specify that
req
is an object with a key ofbody
that is astring
.This may also be a helpful response to check out: https://stackoverflow.com/a/31573441/21533064
I believe the previous answer may in fact be a good solution for you.
JSDoc works with intellisense when applied where a method/function/variable is defined rather than where it’s used. Unfortunately, you won’t be able to give intellisense to parameters of
app.post
(including a callback function) as you have it, because you are invokingapp.post
rather than defining it.Since the second argument to
app.post
is a callback function, and you want to have intellisense inside of it, your best bet is probably to define that function separately (instead of passing it as an anonymous function) so you can give it a JSDoc.Alternatively, you could look into using typescript which has typed intellisense built in for most commonly used packages.