Skip to content

Commit a50001c

Browse files
author
Andy
authored
Treat 'import("")' as a module reference (microsoft#23949)
1 parent 8fc4242 commit a50001c

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

src/services/findAllReferences.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,8 @@ namespace ts.FindAllReferences.Core {
272272
case SyntaxKind.ImportDeclaration:
273273
case SyntaxKind.ExportDeclaration:
274274
return true;
275+
case SyntaxKind.LiteralType:
276+
return isImportTypeNode(node.parent.parent);
275277
case SyntaxKind.CallExpression:
276278
return isRequireCall(node.parent as CallExpression, /*checkArgumentIsStringLiteralLike*/ false) || isImportCall(node.parent as CallExpression);
277279
default:
@@ -407,7 +409,6 @@ namespace ts.FindAllReferences.Core {
407409
return firstDefined(symbol.declarations, decl => {
408410
if (!decl.parent) {
409411
// Assertions for GH#21814. We should be handling SourceFile symbols in `getReferencedSymbolsForModule` instead of getting here.
410-
Debug.assert(decl.kind === SyntaxKind.SourceFile);
411412
Debug.fail(`Unexpected symbol at ${Debug.showSyntaxKind(node)}: ${Debug.showSymbol(symbol)}`);
412413
}
413414
return isTypeLiteralNode(decl.parent) && isUnionTypeNode(decl.parent.parent)
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
/// <reference path='fourslash.ts' />
22

3+
// @Filename: /b.ts
34
////type [|{| "isWriteAccess": true, "isDefinition": true |}T|] = number;
45
////export = [|T|];
56

6-
////const x: [|import("./b")|] = 0;
7+
// @Filename: /a.ts
8+
////const x: import("[|./b|]") = 0;
79

8-
// TODO: GH#23879 should just verify.rangesReferenceEachOther();
10+
// TODO: GH#23879 Should be `verify.singleReferenceGroup("type T = number")
911
const [r0, r1, r2] = test.ranges();
1012
verify.referenceGroups([r0, r1], [{ definition: "type T = number", ranges: [r0, r1] }]);
11-
verify.referenceGroups(r2, undefined);
13+
verify.referenceGroups(r2, [{ definition: 'module "/b"', ranges: [r2] }]);

0 commit comments

Comments
 (0)