Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can VS code auto generate jsdoc with typescript types?

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?

like image 415
r-gee Avatar asked Mar 17 '26 13:03

r-gee


1 Answers

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

like image 112
Jan Pfenning Avatar answered Mar 20 '26 16:03

Jan Pfenning



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!