-
Notifications
You must be signed in to change notification settings - Fork 12.8k
JSDoc support for destructured parameters #11859
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
+1 |
This does not work on version 1.21.1
|
Also an issue when functions return an interface interface Returns {
/** This object contains a getter that returns itself */
get: (key: string) => string;
}
const buildObject = (): Returns => ({
get: key => key
})
// shows jsdoc description when hovering over "obj1.get"
const obj1 = buildObject();
const a = obj1.get("key")
// Only shows signature "const get: (key: string) => string"
const {get} = buildObject();
const b = get("key"); |
Note we could move the jsdoc comments to this interface. But there's an open issue with it: microsoft/TypeScript#11859 (comment)
* Set jumpToFrame async to avoid blocking event loop * Stop getByText throwing errors * Add explicit return type for testSprite Note we could move the jsdoc comments to this interface. But there's an open issue with it: microsoft/TypeScript#11859 (comment) * Include userland stack trace in jumpToFrame
Also would really like to have the comments made in my interface show on hover of destructured variables. In the mean time, has anybody found a workaround? I destructure code all over the place and can't figure out how to document the variables. |
@edbentley What did you mean with
I'm experiencing the same issue where destructured function params don't show the JSDoc comment. : S |
@mesqueeb I just meant that it wasn't worth moving the existing JSDoc comments to the interface since they still won't show. |
Would like to see this implemented for the basic case: interface Options {
/**
* description
*/
param?: string;
}
const options: Options = {};
// `param` has no JSDOC
const { param } = options Any pointers where the implementation should happen (and tests)? Should the description also be carried over if the destructured value has a default value e.g. // Should `param` have the description of `options.param`?
const { param = 'someDefaultValue' } = options |
Maybe https://github.com/microsoft/TypeScript/blob/master/src/services/jsDoc.ts ? |
Looking at this issue a year after subscribing to it, I feel the requirement doesn't make sense if we look at the implications of supporting this. Because if this is implemented then wouldn't it also mean carrying over descriptions at every assignment? Since this
is equivalent to
If the description is really important then maybe something like Nominal Types can be used so a reference to the original type is still around if not it's description, eg.: |
This seems related to this weird issue I'm having with type inference on object destructuring. Posted about it here: #44730 (comment) |
Is JSDoc dead? This has not been fixed in almost 6 years. |
I spent many hours figuring out why docs are sometimes shown and sometimes not. microsoft/TypeScript#11859
See microsoft/TypeScript#11859. Essentially JSDoc should not be used for Typescript
See microsoft/TypeScript#11859. Essentially JSDoc should not be used for Typescript
TypeScript Version: 2.0.3
Code
Expected behavior:
Intellisense for the second argument, or the second argument properties.
Actual behavior:
No way of providing a description for the destructured elements of a destructured parameter.
The text was updated successfully, but these errors were encountered: