-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
Support for JSDoc interface definition #33207
Comments
This is a sub-issue of #30624. Right now we have decided not to make all of Typescript's features available in JSDoc. Writing 40 lines of metadata in a comment is not much different from putting those same lines in a d.ts file, and we believe the d.ts syntax is much more readable to humans. |
@sandersn I tend to agree that the syntax of TS is more readable. But here, I'm not asking to support TS syntax inside JSDoc (which is what I understand from #30624) but to support existing JSDoc features (so that code already using them in JSDoc can be understood by the TS compiler). This is an existing JSDoc syntax for interface (and yes, again, I totally agree that it is lot less readable that the TS syntax). |
I looked for uses of Until we have evidence that people use react-domUses Uses superagentUses ejsSame as superagent, except with nise and sinonUses /** @interface */
function Encoder() {}
Encoder.prototype = {
handler: function(stream, code_point) {}
}; I'm pretty sure this is how closure defines interfaces. chrome-devtools-frontend, firebase and protobufjs also work this way. These are all google projects, so it's not surprising. |
isn't |
We use I am not sure if we can use the |
@TimvdLippe Could you open a separate issue for supporting closure's |
We use |
Search Terms
jsdoc, interface
I found #16142 which was closed by the reporter, and never reopened even though some other people suggested it.
Suggestion
JSDoc has a way to declare interfaces, through
@interface
,@function
(and then@implements
on the class). It would be great if tsc could support them (defining a TS interface based on that info).Use Cases
JSDoc interfaces are useful to define interfaces implemented by multiple classes, that are then used based on this interface. This is part of JSDoc, but currently unsupported by tsc.
Examples
Checklist
My suggestion meets these guidelines:
The text was updated successfully, but these errors were encountered: