Skip to content

Add support for @template JSDoc #1178

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

Closed
NoelAbrahams opened this issue Nov 17, 2014 · 12 comments
Closed

Add support for @template JSDoc #1178

NoelAbrahams opened this issue Nov 17, 2014 · 12 comments
Assignees
Labels
Committed The team has roadmapped this issue Fixed A PR has been merged for this issue Suggestion An idea for TypeScript

Comments

@NoelAbrahams
Copy link

Hi, it will be useful to be able to document generic parameters:

/** The foo class.
  * @template TFirst ...
  * @template TSecond ... */
class Foo<TFirst, TSecond> {

}

var foo = new Foo< // Info
@johnnyreilly
Copy link

+1 for this

@danquirk
Copy link
Member

This tag appears to be undocumented but supported in WebStorm for this same purpose so may be reasonable to go ahead with it (http://stackoverflow.com/questions/16017627/document-generic-type-parameters-in-jsdoc).

@danquirk danquirk added Suggestion An idea for TypeScript Visual Studio Integration with Visual Studio labels Nov 17, 2014
@mhegazy mhegazy removed the Visual Studio Integration with Visual Studio label Dec 3, 2015
@kitsonk
Copy link
Contributor

kitsonk commented Dec 3, 2015

Carried over from #5854, it was pointed out that Closure Compiler documents this feature.

@mhegazy mhegazy added the Committed The team has roadmapped this issue label Dec 9, 2015
@RyanCavanaugh RyanCavanaugh added the Fixed A PR has been merged for this issue label Jun 23, 2016
@Liero
Copy link

Liero commented Jul 1, 2016

I'm not sure what is the final syntax for documenting generic arguments. Can you point to documentation or briefly describe, please?

@billti
Copy link
Member

billti commented Jul 1, 2016

@unional
Copy link
Contributor

unional commented Jul 14, 2016

@RyanCavanaugh is it in nightly? I check and 2.1.0-dev.20160712 does not work:
image
image

The "@template T Inferred ...." is treated as part of summary.

@mhegazy
Copy link
Contributor

mhegazy commented Jul 19, 2016

@unional can you log a new issue with more details

@unional
Copy link
Contributor

unional commented Jul 19, 2016

Done. 🌷

@zpdDG4gta8XKpMCd
Copy link

please update https://github.com/Microsoft/TypeScript/wiki/JSDoc-support-in-JavaScript

@art-in
Copy link

art-in commented Dec 3, 2017

so narrowing generic type @template T is supported?
the case was mentioned in #5854, but I cannot find any example.

same question: https://stackoverflow.com/questions/44080759/is-it-possible-to-constrain-a-generic-type-defined-in-a-jsdoc-template-declarat

@villelahdenvuo
Copy link

I just came to ask the same question, but it seems like the answer is no.

@mhegazy
Copy link
Contributor

mhegazy commented Dec 4, 2017

Looking at the closure documentation for @template (https://github.com/google/closure-compiler/wiki/Generic-Types), does not seem that the standard has any support for this. One option is to make a new syntax, @template T {Object} to define a constraint. I would file a new suggestion for that.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Committed The team has roadmapped this issue Fixed A PR has been merged for this issue Suggestion An idea for TypeScript
Projects
None yet
Development

No branches or pull requests