Skip to content
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

@template tag does not generate generic parameters #134

Closed
thw0rted opened this issue May 29, 2020 · 2 comments
Closed

@template tag does not generate generic parameters #134

thw0rted opened this issue May 29, 2020 · 2 comments

Comments

@thw0rted
Copy link

I'm trying to document generics and while the tags are correctly interpreted by Typescript directly, tsd-jsdoc is not applying type parameters in its output.

I put together a simple repro and nothing I do there is able to get the output to include type parameters in the declaration.


Once this is worked out, I also wanted to see if there is supposed to be any syntax for specifying a default value for type parameters, as in MyClass<T extends Function = Function>. That isn't listed on the Closure documentation about Generics and it sounds like the TS team is still debating, so I could open a separate issue if need be.

@englercj
Copy link
Owner

englercj commented May 29, 2020

There is an example in the tests that successfully generates a class with a generic template:

/**
* @classdesc
* A Foo.
*
* @constructor
* @template T
*/
FoobarNS.Foo = function Foo() {
};

@thw0rted
Copy link
Author

Welp, it's right there on the front page 😳

If you want to use supported ClosureCompiler features, you also need to specify this module as a pluginin your JSON configuration

Adding "plugins": [ "./node_modules/tsd-jsdoc/dist/plugin" ], to my ts-conf.json immediately resolved the issue. I'm sorry I missed that, and thanks for pointing me in the right direction, @englercj .

Should I open a second issue about supporting type parameter bounds and default values? Currently, whatever follows @template is shoved into the type parameter verbatim, so I can actually write @template FuncType extends Function = Function and it compiles to declare class GenericClass<SomeType extends Function = Function>. This is what I want, but it's not correct per the Closure spec or Typescript's own interpretation of the @template tag. Both of those support @template {Function} FuncType, and as far as I can tell neither of them actually have a syntax for supplying a default value at all.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants