Treat 'import("")' as a module reference (#23949)

This commit is contained in:
Andy
2018-05-07 15:42:36 -07:00
committed by GitHub
parent 8fc4242097
commit a50001c9da
2 changed files with 7 additions and 4 deletions

View File

@@ -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)

View File

@@ -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] }]);