Skip to content

Commit 4a39caf

Browse files
author
Andy
authored
Use isExternalModuleImportEquals in one more place (#22417)
1 parent ea8904e commit 4a39caf

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

src/services/importTracker.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -394,18 +394,16 @@ namespace ts.FindAllReferences {
394394
case SyntaxKind.ExportDeclaration:
395395
case SyntaxKind.ImportDeclaration: {
396396
const decl = statement as ImportDeclaration | ExportDeclaration;
397-
if (decl.moduleSpecifier && decl.moduleSpecifier.kind === SyntaxKind.StringLiteral) {
398-
action(decl, decl.moduleSpecifier as StringLiteral);
397+
if (decl.moduleSpecifier && isStringLiteral(decl.moduleSpecifier)) {
398+
action(decl, decl.moduleSpecifier);
399399
}
400400
break;
401401
}
402402

403403
case SyntaxKind.ImportEqualsDeclaration: {
404404
const decl = statement as ImportEqualsDeclaration;
405-
const { moduleReference } = decl;
406-
if (moduleReference.kind === SyntaxKind.ExternalModuleReference &&
407-
moduleReference.expression.kind === SyntaxKind.StringLiteral) {
408-
action(decl, moduleReference.expression as StringLiteral);
405+
if (isExternalModuleImportEquals(decl)) {
406+
action(decl, decl.moduleReference.expression);
409407
}
410408
break;
411409
}
@@ -647,7 +645,7 @@ namespace ts.FindAllReferences {
647645
return node.kind === SyntaxKind.ModuleDeclaration && (node as ModuleDeclaration).name.kind === SyntaxKind.StringLiteral;
648646
}
649647

650-
function isExternalModuleImportEquals({ moduleReference }: ImportEqualsDeclaration): boolean {
651-
return moduleReference.kind === SyntaxKind.ExternalModuleReference && moduleReference.expression.kind === SyntaxKind.StringLiteral;
648+
function isExternalModuleImportEquals(eq: ImportEqualsDeclaration): eq is ImportEqualsDeclaration & { moduleReference: { expression: StringLiteral } } {
649+
return eq.moduleReference.kind === SyntaxKind.ExternalModuleReference && eq.moduleReference.expression.kind === SyntaxKind.StringLiteral;
652650
}
653651
}

0 commit comments

Comments
 (0)