Skip to content

Commit 5bd4e00

Browse files
authored
Skip markLinkedReferences import elision walk entirely in some common cases (#59398)
1 parent 4992b2f commit 5bd4e00

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
@@ -49579,11 +49579,14 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
4957949579

4958049580
function checkSingleIdentifier(node: Node) {
4958149581
const nodeLinks = getNodeLinks(node);
49582-
nodeLinks.calculatedFlags |= NodeCheckFlags.ConstructorReference | NodeCheckFlags.CapturedBlockScopedBinding | NodeCheckFlags.BlockScopedBindingInLoop;
49583-
if (isIdentifier(node) && isExpressionNodeOrShorthandPropertyAssignmentName(node) && !(isPropertyAccessExpression(node.parent) && node.parent.name === node)) {
49584-
const s = getResolvedSymbol(node);
49585-
if (s && s !== unknownSymbol) {
49586-
checkIdentifierCalculateNodeCheckFlags(node, s);
49582+
nodeLinks.calculatedFlags |= NodeCheckFlags.ConstructorReference;
49583+
if (isIdentifier(node)) {
49584+
nodeLinks.calculatedFlags |= NodeCheckFlags.BlockScopedBindingInLoop | NodeCheckFlags.CapturedBlockScopedBinding; // Can't set on all arbitrary nodes (these nodes have this flag set by `checkSingleBlockScopeBinding` only)
49585+
if (isExpressionNodeOrShorthandPropertyAssignmentName(node) && !(isPropertyAccessExpression(node.parent) && node.parent.name === node)) {
49586+
const s = getResolvedSymbol(node);
49587+
if (s && s !== unknownSymbol) {
49588+
checkIdentifierCalculateNodeCheckFlags(node, s);
49589+
}
4958749590
}
4958849591
}
4958949592
}

src/compiler/emitter.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -961,6 +961,7 @@ export function emitFiles(
961961
}
962962

963963
function markLinkedReferences(file: SourceFile) {
964+
if (ts.isSourceFileJS(file)) return; // JS files don't use reference calculations as they don't do import ellision, no need to calculate it
964965
ts.forEachChildRecursively(file, n => {
965966
if (isImportEqualsDeclaration(n) && !(ts.getSyntacticModifierFlags(n) & ts.ModifierFlags.Export)) return "skip"; // These are deferred and marked in a chain when referenced
966967
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)