-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Suggestion: Generics and JSDoc #5854
New issue
Have a question about this project? No Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “No 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? No Sign in to your account
Comments
Actually, the closure compiler specifies |
@weswigham thanks! Ok, then I suggest the following: /**
* My generic function
* @param {T} value Some sort of generic thing
* @returns {T} and I will just it back to you
* @template T Give me some generic goodness
*/
function foo<T extends string>(value: T): T {
return value;
} The one limitation is that it |
I'm working on JSDoc support now and will keep this in mind |
Note @RyanCavanaugh that the initial work @CyrusNajmabadi did already had support for the JsDoc @template tag (see 0cb45c5 ). |
|
indeed. thanks @NoelAbrahams |
Related to both #2913 and #2916, it is great having support for JSDoc annotations. One thing that does make using TypeScript with JSDoc a little bit of a challenge is how to annotate Generics. You can supply a lot of information to a consumer of the API now, but if you have generics, the consumer might be left wondering "what is this generic used for, what should I pass?"
There doesn't seem to be an appropriate tag for it in JSDoc. I am suggesting that maybe
@generic
would be appropriate, where the generic is named like a param is named and the type annotation would be if the generic extends another type. For example:The text was updated successfully, but these errors were encountered: