12

If I have some function like this:

const function = (param: string) => {
 // ...
}

Now in VS Code if I start typing /** above so that it generates the docs, it gives this:

/**
 *
 * @param param
 */
const function = (param: string) => {
 // ...
}

But I want it to also automatically generate the type from the typescript information, like this:

/**
 *
 * @param {string} param
 */
const function = (param: string) => {
 // ...
}

Is this possible?

Said Torres
  • 581
  • 3
  • 14
r-gee
  • 121
  • 2

2 Answers2

2

There is a VS-Code extension called Document This which will do the trick for you

It creates

/**
 *
 *
 * @param {string} param
 */
const f = (param: string) => {
  // ...
}

from

const f = (param: string) => {
  // ...
}

by positioning the cursor above the function and executing Ctrl+Alt+D twice

0

According to this article on VS Code's site https://code.visualstudio.com/docs/languages/javascript#_jsdoc-support there is native support for JS Docs in visual studio code.

The image shows that types needs to be inputted manually.

It looks like you need a third party plugin to do this for the time being.

If you want native support for this, create a github issue https://github.com/microsoft/vscode/issues and it could potentially be added by a contributor. Otherwise an extension might be best for this.