Skip to content

Fix @typedef/@callback scope#43682

Merged
sandersn merged 1 commit into
masterfrom
correct-jsdoc-typedef-scope
Apr 14, 2021
Merged

Fix @typedef/@callback scope#43682
sandersn merged 1 commit into
masterfrom
correct-jsdoc-typedef-scope

Conversation

@sandersn
Copy link
Copy Markdown
Member

JSDoc typedefs don't actually have hosts, because they're not semantically attached to a declaration. However, the parser still attaches them to some declaration (or statement), but that declaration is not related to the typedef.

Previously, delayedBindJSDocTypedefTag used getJSDocHost to walk past the unrelated declaration, but #41858 correctly started categorising typedefs as unattached, with no host, so the binder began falling back to file scope.

The path through the tree to skip the unrelated declaration is always the same, though, so this PR uses typeAlias.parent.parent instead of getJSDocHost(typeAlias).

Fixes #43576

JSDoc typedefs don't actually have hosts, because they're not
semantically attached to a declaration. However, the parser still
attaches them to some declaration (or statement), but that declaration
is not related to the typedef.

Previously, delayedBindJSDocTypedefTag used getJSDocHost to walk past
the unrelated declaration, but #41858 correctly started categorising
typedefs as unattached, with no host, so the binder began falling
back to file scope.

The path to skip the unrelated declaration is always the same, though, so this
PR uses `typeAlias.parent.parent` instead of `getJSDocHost(typeAlias)`.
@typescript-bot typescript-bot added Author: Team For Milestone Bug PRs that fix a bug with a specific milestone labels Apr 14, 2021
@sandersn sandersn merged commit 3f93d42 into master Apr 14, 2021
@sandersn sandersn deleted the correct-jsdoc-typedef-scope branch April 14, 2021 23:56
@microsoft microsoft locked as resolved and limited conversation to collaborators Oct 21, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Author: Team For Milestone Bug PRs that fix a bug with a specific milestone

Projects

None yet

Development

Successfully merging this pull request may close these issues.

JSDoc typedefs disregard functions scopes since VS Code 1.54.1

4 participants