Bug Report
π Search Terms
jsdoc name resolve lookup symbol template constraint typedef
π Version & Regression Information
- This has been an issue since we added support for
@template in JSDoc
β― Playground Link
Playground link with relevant code
π» Code
/**
* @template T
* @template {keyof T} K
* @typedef Foo
*/
π Actual behavior
Reports Cannot find name `T`.
π Expected behavior
Does not report an error.
Notes
Name resolution does not look at the symbol table of the @typedef tag, so when looking for T in the code below, we end up looking at T for the function declaration further down in this example:
/**
* @template T
* @template {keyof T} K
* @typedef Foo
*/
/**
* @template T
* @param {T} a
*/
function bar(a) {
}
A "go-to-definition" on the T in keyof T jumps to the T declared for bar, not the T in the typedef for Foo.
Bug Report
π Search Terms
jsdoc name resolve lookup symbol template constraint typedef
π Version & Regression Information
@templatein JSDocβ― Playground Link
Playground link with relevant code
π» Code
π Actual behavior
Reports
Cannot find name `T`.π Expected behavior
Does not report an error.
Notes
Name resolution does not look at the symbol table of the
@typedeftag, so when looking forTin the code below, we end up looking atTfor the function declaration further down in this example:A "go-to-definition" on the
Tinkeyof Tjumps to theTdeclared forbar, not theTin the typedef forFoo.