@@ -394,18 +394,16 @@ namespace ts.FindAllReferences {
394
394
case SyntaxKind . ExportDeclaration :
395
395
case SyntaxKind . ImportDeclaration : {
396
396
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 ) ;
399
399
}
400
400
break ;
401
401
}
402
402
403
403
case SyntaxKind . ImportEqualsDeclaration : {
404
404
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 ) ;
409
407
}
410
408
break ;
411
409
}
@@ -647,7 +645,7 @@ namespace ts.FindAllReferences {
647
645
return node . kind === SyntaxKind . ModuleDeclaration && ( node as ModuleDeclaration ) . name . kind === SyntaxKind . StringLiteral ;
648
646
}
649
647
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 ;
652
650
}
653
651
}
0 commit comments