mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-07-02 14:48:32 -05:00
Treat 'import("")' as a module reference (#23949)
This commit is contained in:
@@ -272,6 +272,8 @@ namespace ts.FindAllReferences.Core {
|
||||
case SyntaxKind.ImportDeclaration:
|
||||
case SyntaxKind.ExportDeclaration:
|
||||
return true;
|
||||
case SyntaxKind.LiteralType:
|
||||
return isImportTypeNode(node.parent.parent);
|
||||
case SyntaxKind.CallExpression:
|
||||
return isRequireCall(node.parent as CallExpression, /*checkArgumentIsStringLiteralLike*/ false) || isImportCall(node.parent as CallExpression);
|
||||
default:
|
||||
@@ -407,7 +409,6 @@ namespace ts.FindAllReferences.Core {
|
||||
return firstDefined(symbol.declarations, decl => {
|
||||
if (!decl.parent) {
|
||||
// Assertions for GH#21814. We should be handling SourceFile symbols in `getReferencedSymbolsForModule` instead of getting here.
|
||||
Debug.assert(decl.kind === SyntaxKind.SourceFile);
|
||||
Debug.fail(`Unexpected symbol at ${Debug.showSyntaxKind(node)}: ${Debug.showSymbol(symbol)}`);
|
||||
}
|
||||
return isTypeLiteralNode(decl.parent) && isUnionTypeNode(decl.parent.parent)
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
// @Filename: /b.ts
|
||||
////type [|{| "isWriteAccess": true, "isDefinition": true |}T|] = number;
|
||||
////export = [|T|];
|
||||
|
||||
////const x: [|import("./b")|] = 0;
|
||||
// @Filename: /a.ts
|
||||
////const x: import("[|./b|]") = 0;
|
||||
|
||||
// TODO: GH#23879 should just verify.rangesReferenceEachOther();
|
||||
// TODO: GH#23879 Should be `verify.singleReferenceGroup("type T = number")
|
||||
const [r0, r1, r2] = test.ranges();
|
||||
verify.referenceGroups([r0, r1], [{ definition: "type T = number", ranges: [r0, r1] }]);
|
||||
verify.referenceGroups(r2, undefined);
|
||||
verify.referenceGroups(r2, [{ definition: 'module "/b"', ranges: [r2] }]);
|
||||
|
||||
Reference in New Issue
Block a user