Closed
Description
Expected behavior
No error.
Actual behavior
The type 'F' is undefined.
ESLint Config
{
"env": {
"es6": true
},
"parserOptions": {
"ecmaVersion": "latest",
"sourceType": "module"
},
"plugins": ["jsdoc"],
"rules": {
"jsdoc/no-undefined-types": "error"
},
"settings": {
"jsdoc": {
"mode": "typescript"
}
}
}
export class Food {}
export class Soup extends Food {}
export class Donut extends Food {}
/**
* @template {Food} [F=Soup]
*/
export class Restaurant {
/**
* @param {Array<F>} menu The menu items.
*/
constructor(menu) {
/**
* @private
* @type {Array<F>}
*/
this.menu = [];
}
}
Environment
- Node version: v17.5.0
- ESLint version v8.0.0
eslint-plugin-jsdoc
version: 39.3.0
Details
When a template tag is declared like @template {Food} F
, the no-undefined-types
rule works. If the template tag has a default like @template {Food} [F=Soup]
, then the no-undefined-types
rule does not work.
Support for defaults in template tags was added in TypeScript 4.5 (see microsoft/TypeScript#45483).
Previous improvements to the no-undefined-types
rule when using template tags: