-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Open
Labels
Awaiting More FeedbackThis means we'd like to hear from more people who would be helped by this featureThis means we'd like to hear from more people who would be helped by this featureSuggestionAn idea for TypeScriptAn idea for TypeScript
Description
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).
Metadata
Metadata
Assignees
Labels
Awaiting More FeedbackThis means we'd like to hear from more people who would be helped by this featureThis means we'd like to hear from more people who would be helped by this featureSuggestionAn idea for TypeScriptAn idea for TypeScript