-
Notifications
You must be signed in to change notification settings - Fork 134
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
RFC: Support for @typeparam or @template for documenting generic parameters #72
Comments
I like Official JSDoc doesn't support either, so maybe have some freedom to choose which tag to use. The grammar should be pretty much identical to |
I used @template in previous codebases. I think the word came from c++. @typeparam make more sense in TypeScript context. |
I like this idea, but usually I solve this by giving the template parameters a better name. class MyClass<TValue> {
public value: TValue
constructor (value: TValue) {
this.value = value
}
} But I imagine there will be scenarios where having documentation for template parameters would be useful. I also found this in the TypeScript wiki: https://github.com/Microsoft/TypeScript/wiki/JsDoc-support-in-JavaScript#template Looks like the compiler went with |
@dschnare I agree with you that type parameters should have meaningful names, especially if there is more than on of it. However, sometimes it makes sense to explain a type parameter. For example I have a class with a class Example<Parameters> {
...
render(paramters: Parameters) {
...
}
} Usage is like this: const e = new Example<{a: number, b: string}>();
e.render({a: 123, b: 'test'}) If I could explain this parameter, it would improve my API. /**
* @typeparam Parameters Shape of the object containing variables for rendering the template,
* e.g. `Example<{a: number, b: string}>`.
*/
class Example<Parameters> {
``` |
FYI @rbuckton recently implemented support for |
Does TSDoc require
|
I threw together a PR that adds support for synonyms so that |
In #8 (comment) @aciccarello wrote:
The text was updated successfully, but these errors were encountered: