Add Type information for JavaScript constant or variable in vs-code

ivanwonder
Sep 7, 2018 · 1 min read

Write JavaScript with vs-code(except for the typescript), I find many variable or function argument’s type is ‘any’, and I can’t get the convenient from the strong IntelliSense.

After search it online, JSDoc comments is a solution for the problem. use ‘@param {type}’ to tag you function parameter’s type, use ‘@returns {type}’ to specify the return value of function, use ‘@type {type}’ to specify the type for a constant or a variable where the comment is placed. More information can read on the site below.

vs-code know the JSDoc comments, and provide a completion based on the variable you specify.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade