Skip to content

Commit e0701af

Browse files
weswighamtypescript-bot
authored andcommitted
Skip markLinkedReferences import elision walk entirely in some common cases (#59398)
1 parent c8a7d58 commit e0701af

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

src/compiler/checker.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49271,11 +49271,14 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
4927149271

4927249272
function checkSingleIdentifier(node: Node) {
4927349273
const nodeLinks = getNodeLinks(node);
49274-
nodeLinks.calculatedFlags |= NodeCheckFlags.ConstructorReference | NodeCheckFlags.CapturedBlockScopedBinding | NodeCheckFlags.BlockScopedBindingInLoop;
49275-
if (isIdentifier(node) && isExpressionNodeOrShorthandPropertyAssignmentName(node) && !(isPropertyAccessExpression(node.parent) && node.parent.name === node)) {
49276-
const s = getResolvedSymbol(node);
49277-
if (s && s !== unknownSymbol) {
49278-
checkIdentifierCalculateNodeCheckFlags(node, s);
49274+
nodeLinks.calculatedFlags |= NodeCheckFlags.ConstructorReference;
49275+
if (isIdentifier(node)) {
49276+
nodeLinks.calculatedFlags |= NodeCheckFlags.BlockScopedBindingInLoop | NodeCheckFlags.CapturedBlockScopedBinding; // Can't set on all arbitrary nodes (these nodes have this flag set by `checkSingleBlockScopeBinding` only)
49277+
if (isExpressionNodeOrShorthandPropertyAssignmentName(node) && !(isPropertyAccessExpression(node.parent) && node.parent.name === node)) {
49278+
const s = getResolvedSymbol(node);
49279+
if (s && s !== unknownSymbol) {
49280+
checkIdentifierCalculateNodeCheckFlags(node, s);
49281+
}
4927949282
}
4928049283
}
4928149284
}

src/compiler/emitter.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -947,6 +947,7 @@ export function emitFiles(resolver: EmitResolver, host: EmitHost, targetSourceFi
947947
}
948948

949949
function markLinkedReferences(file: SourceFile) {
950+
if (ts.isSourceFileJS(file)) return; // JS files don't use reference calculations as they don't do import ellision, no need to calculate it
950951
ts.forEachChildRecursively(file, n => {
951952
if (isImportEqualsDeclaration(n) && !(ts.getSyntacticModifierFlags(n) & ts.ModifierFlags.Export)) return "skip"; // These are deferred and marked in a chain when referenced
952953
if (ts.isImportDeclaration(n)) return "skip"; // likewise, these are ultimately what get marked by calls on other nodes - we want to skip them

0 commit comments

Comments
 (0)