Skip to content

Commit 27c0c92

Browse files
committed
Simplify even more
1 parent fafd048 commit 27c0c92

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/compiler/checker.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7312,7 +7312,11 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
73127312
// It'd likely be better to store this somewhere else for isSymbolAccessible, but
73137313
// since that API _only_ uses the enclosing declaration (and its parents), this is
73147314
// seems like the best way to inject names into that search process.
7315-
const existingFakeScope = findAncestor(context.enclosingDeclaration, node => !!getNodeLinks(node).fakeScopeForSignatureDeclaration);
7315+
//
7316+
// Note that we only check the most immediate enclosingDeclaration; the only place we
7317+
// could potentially add another fake scope into the chain is right here, so we don't
7318+
// traverse all ancestors.
7319+
const existingFakeScope = getNodeLinks(context.enclosingDeclaration).fakeScopeForSignatureDeclaration ? context.enclosingDeclaration : undefined;
73167320
Debug.assertOptionalNode(existingFakeScope, isBlock);
73177321

73187322
const locals = existingFakeScope?.locals ?? createSymbolTable();
@@ -8074,7 +8078,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
80748078
}
80758079

80768080
function getEnclosingDeclarationIgnoringFakeScope(enclosingDeclaration: Node) {
8077-
return findAncestor(enclosingDeclaration, n => !getNodeLinks(n).fakeScopeForSignatureDeclaration);
8081+
return getNodeLinks(enclosingDeclaration).fakeScopeForSignatureDeclaration ? enclosingDeclaration.parent : enclosingDeclaration;
80788082
}
80798083

80808084
/**

0 commit comments

Comments
 (0)