Bug Report
I'm using tsc to create a .d.ts file from jsdoc comments in my JavaScript source files. When I scope a custom type definition using the "~" character, if the parameter is optional, it will not be in the outputted .d.ts.
According to jsdoc documentation, this is the correct way to scope a callback to a specific class.
💻 Code
JavaScript source:
class Test {
/**
* @callback Test~myCallback
* @param {string} [name] Event name
*/
/**
* @method
* @param {string} [event] Event name.
* @param {Test~myCallback} [callback] The callback
*/
removeListener(event, callback) {
}
}
Outputted .d.ts file:
declare class Test {
removeListener(event?: string, callback: any): void;
}
🙁 Actual behaviour
The output renders "callback" as if mandatory. This is invalid as a mandatory parameter cannot follow an optional one. Also, the type is "any", event though I defined a custom type.
🙂 Expected behaviour
The "callback" parameter should be optional as specified in the source JavaScript. The type should be "Test~myCallback" (or however TypeScript deals with these).
Bug Report
I'm using
tscto create a.d.tsfile from jsdoc comments in my JavaScript source files. When I scope a custom type definition using the "~" character, if the parameter is optional, it will not be in the outputted.d.ts.According to jsdoc documentation, this is the correct way to scope a callback to a specific class.
💻 Code
JavaScript source:
Outputted
.d.tsfile:🙁 Actual behaviour
The output renders "callback" as if mandatory. This is invalid as a mandatory parameter cannot follow an optional one. Also, the type is "any", event though I defined a custom type.
🙂 Expected behaviour
The "callback" parameter should be optional as specified in the source JavaScript. The type should be "Test~myCallback" (or however TypeScript deals with these).