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

Incorrect name resolution for JSDoc template tag constraints in typedef #45480

Closed
rbuckton opened this issue Aug 17, 2021 · 1 comment Β· Fixed by #45483
Closed

Incorrect name resolution for JSDoc template tag constraints in typedef #45480

rbuckton opened this issue Aug 17, 2021 · 1 comment Β· Fixed by #45483
Labels
Bug A bug in TypeScript Domain: JSDoc Relates to JSDoc parsing and type generation
Milestone

Comments

@rbuckton
Copy link
Member

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.

@RyanCavanaugh RyanCavanaugh added the Bug A bug in TypeScript label Aug 17, 2021
@RyanCavanaugh RyanCavanaugh added this to the Backlog milestone Aug 17, 2021
@RyanCavanaugh RyanCavanaugh added the Domain: JSDoc Relates to JSDoc parsing and type generation label Aug 17, 2021
@awerlogus
Copy link

Duplicate of #43403

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Domain: JSDoc Relates to JSDoc parsing and type generation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants