mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-16 15:45:27 -05:00
Fix @typedef/@callback scope (#43682)
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)`.
This commit is contained in:
committed by
GitHub
parent
3ab6809e38
commit
3f93d420bf
@@ -2123,9 +2123,9 @@ namespace ts {
|
||||
const saveParent = parent;
|
||||
const saveCurrentFlow = currentFlow;
|
||||
for (const typeAlias of delayedTypeAliases) {
|
||||
const host = getJSDocHost(typeAlias);
|
||||
container = (host && findAncestor(host.parent, n => !!(getContainerFlags(n) & ContainerFlags.IsContainer))) || file;
|
||||
blockScopeContainer = (host && getEnclosingBlockScopeContainer(host)) || file;
|
||||
const host = typeAlias.parent.parent;
|
||||
container = findAncestor(host.parent, n => !!(getContainerFlags(n) & ContainerFlags.IsContainer)) || file;
|
||||
blockScopeContainer = getEnclosingBlockScopeContainer(host) || file;
|
||||
currentFlow = initFlowNode({ flags: FlowFlags.Start });
|
||||
parent = typeAlias;
|
||||
bind(typeAlias.typeExpression);
|
||||
|
||||
Reference in New Issue
Block a user