@@ -7272,7 +7272,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
7272
7272
//
7273
7273
// If the declaration is in a JS file, then we don't need to do this at all, as there are no annotations besides
7274
7274
// JSDoc, which are always outside the function declaration, so are not in the parameter scope.
7275
- let restoreEnclosingDeclaration : (() => void) | undefined;
7275
+ let cleanup : (() => void) | undefined;
7276
7276
if (
7277
7277
context.enclosingDeclaration
7278
7278
&& signature.declaration
@@ -7292,11 +7292,10 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
7292
7292
// It'd likely be better to store this somewhere else for isSymbolAccessible, but
7293
7293
// since that API _only_ uses the enclosing declaration (and its parents), this is
7294
7294
// seems like the best way to inject names into that search process.
7295
- const locals = context.fakeScopeLocals ??= createSymbolTable();
7295
+ const existingFakeScope = findAncestor(context.enclosingDeclaration, node => !!getNodeLinks(node).fakeScopeForSignatureDeclaration);
7296
+ Debug.assertOptionalNode(existingFakeScope, isBlock);
7296
7297
7297
- // Performance optimization; if this is empty then we're not going to find a fake scope
7298
- // in the parents of context.enclosingDeclaration, so skip searching later.
7299
- const couldHaveFakeScopeAncestor = !!locals.size;
7298
+ const locals = existingFakeScope?.locals ?? createSymbolTable();
7300
7299
7301
7300
let newLocals: __String[] | undefined;
7302
7301
for (const param of expandedParams) {
@@ -7311,8 +7310,8 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
7311
7310
forEach(newLocals, s => locals.delete(s));
7312
7311
}
7313
7312
7314
- if (couldHaveFakeScopeAncestor && findAncestor(context.enclosingDeclaration, node => !!getNodeLinks(node).fakeScopeForSignatureDeclaration) ) {
7315
- restoreEnclosingDeclaration = removeNewLocals;
7313
+ if (existingFakeScope ) {
7314
+ cleanup = removeNewLocals;
7316
7315
}
7317
7316
else {
7318
7317
// Use a Block for this; the type of the node doesn't matter so long as it
@@ -7325,7 +7324,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
7325
7324
setParent(fakeScope, saveEnclosingDeclaration);
7326
7325
context.enclosingDeclaration = fakeScope;
7327
7326
7328
- restoreEnclosingDeclaration = () => {
7327
+ cleanup = () => {
7329
7328
context.enclosingDeclaration = saveEnclosingDeclaration;
7330
7329
removeNewLocals();
7331
7330
};
@@ -7388,7 +7387,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
7388
7387
node.typeArguments = factory.createNodeArray(typeArguments);
7389
7388
}
7390
7389
7391
- restoreEnclosingDeclaration ?.();
7390
+ cleanup ?.();
7392
7391
return node;
7393
7392
}
7394
7393
@@ -48551,7 +48550,6 @@ interface NodeBuilderContext {
48551
48550
usedSymbolNames?: Set<string>;
48552
48551
remappedSymbolNames?: Map<SymbolId, string>;
48553
48552
reverseMappedStack?: ReverseMappedSymbol[];
48554
- fakeScopeLocals?: SymbolTable;
48555
48553
}
48556
48554
48557
48555
class SymbolTrackerImpl implements SymbolTracker {
0 commit comments