-
Notifications
You must be signed in to change notification settings - Fork 12.8k
JSDoc : support @interface and @implements (and more) #41675
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
I also really need '@interface' support, I expect to use type federation in JS to support multiple type merges (based on JSDoc) |
Potential Use Cases for
|
Some initial comments and questions.
|
1) Potential Syntax for InterfacesIt depends on TypeScript's goal. I think the syntax suggested by the OP is based on what's currently acknowledged by JSDocs. If TypeScript is willing to deviate from this, then I would agree that this syntax is not particularly pleasing. Perhaps a better syntax would be something similar to what /**
* I describe `MyType` (if I'm the only description).
* @typedef {Object} MyType I also describe `MyType`.
* Yep. I describe `MyType` as well.
*
*
* Hey! I describe `MyType` too! And because there's at least 1 line of space between me and the previous
* comment, I create a newline in the IntelliSense bubble.
* @property {string} propString I don't describe `MyType`. I describe `propString`.
* I also describe `propString`.
*
*
*
* All the way down here, I am also a description for `propString`.
* @property {number} propLast I describe `propLast`.
*
*
*
* From now on, `propLast` calls the shots.
*/ So One thing that I don't favor about /**
* I describe `MyInterface` (if I'm the only description).
* @interface MyInterface I also describe `MyInterface`.
*
* Indeed. I, too, describe `MyInterface`.
* @property {string} propString I describe `propString`.
*
*
*
* I also describe `propString`.
* @method myMethod I describe `myMethod`.
* @param {number} firstArgument I describe `firstArgument`, within `myMethod`.
*
* I also describe `firstArgument`.
* @returns {void} I am telling you what `myMethod` returns.
*
* @example
* // I am an example belonging to `myMethod`.
* const variableInExample = "5";
*
* @property {boolean} propBoolean I create a new "scope" for descriptions. So from now on, all
* comments and "non-important tags" belong to me.
*
* For instance, even though a @see is here, it is still part of the description for `propBoolean`.
*/ I'm not sure how possible this is. But if it is possible, I think this would make sense. It's pretty similar to the I'm sure alternatives are also possible. Thoughts? 2) Controlled Exposure of JSDoc TypesSomething like an 3) Compilation or No Compilation?Current Experience: Compilation Required for Production Release, but not during DevelopmentThankfully, no compilation step is required during development. Unfortunately, production release is a different story. When a user imports from a Consequently, my project has a build step. Because the
Because the generated Desired Experience: No Required Build Step at AllIf a project is only using JS (and perhaps some accompanying, non-compiled Currently, as long as I'm writing code locally (in VS Code) or running tests, the type support is great! TypeScript throws errors when I break the types, and I get all the IntelliSense that I need to know what's going on. (There's also the bonus of avoiding type-related bugs that come from compilation, as in the case of generic constructors and method overloads.) It's the It would be amazing if TypeScript could read the types from the 4) TS Designs Supporting PureJS ScenariosThat's really helpful to know! That is indeed my ideal. 😅 Being able to use pure JS to skip the build step would be really helpful. It would also help with debugging when end users run into problems (because the source -- including types -- would be in |
I would like to re-open an issue: #16142
As it is locked I am to open this new issue.
I personally do not like TypeScript as a language, I do however, like TypeScript as a tool for my JavaScript projects, hence why I would like more support for JSDoc.
Code
In a JavaScript file, with checkJs option :
Actual behavior:
No error.
Expected behavior:
An error should be raised. It's important in checkJs mode as JavaScript doesn't have native interfaces.
The text was updated successfully, but these errors were encountered: