Suggestion
Add support for type parameter defaults in JSDoc @template tags, to match parity with type parameter defaults in TypeScript:
// ts
type Foo<T = number> = T
// js
/**
* @template [T=number]
* @typedef {T} Foo
*/
🔍 Search Terms
jsdoc template type parameter default
✅ Viability Checklist
My suggestion meets these guidelines:
⭐ Suggestion
Implement type parameter defaults in @template similar to optional parameters in @param:
/**
* @param {string} [x=1] - NOTE: TS parses the expression `1` but ignores it.
*/
function f(x) {}
/**
* @template {string} [T="hello"]
* @typedef {T} Foo
*/
- Brackets around
T would be required (so as not to misinterpret existing documentation comments
- A bracketed template type must have a default (unlike
@param which allows [name] on its own).
📃 Motivating Example
Improves JavaScript JSDoc type annotation parity with TypeScript type annotations.
💻 Use Cases
Used for JavaScript development using the TypeScript language service.
Suggestion
Add support for type parameter defaults in JSDoc
@templatetags, to match parity with type parameter defaults in TypeScript:🔍 Search Terms
jsdoc template type parameter default
✅ Viability Checklist
My suggestion meets these guidelines:
⭐ Suggestion
Implement type parameter defaults in
@templatesimilar to optional parameters in@param:Twould be required (so as not to misinterpret existing documentation comments@paramwhich allows[name]on its own).📃 Motivating Example
Improves JavaScript JSDoc type annotation parity with TypeScript type annotations.
💻 Use Cases
Used for JavaScript development using the TypeScript language service.