mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-06 20:14:01 -06:00
Implement LS on string-literal of dynamic import
This commit is contained in:
parent
cae1286b72
commit
2e55b6ae16
@ -22665,14 +22665,16 @@ namespace ts {
|
||||
return undefined;
|
||||
|
||||
case SyntaxKind.StringLiteral:
|
||||
// External module name in an import declaration
|
||||
if ((isExternalModuleImportEqualsDeclaration(node.parent.parent) &&
|
||||
getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) ||
|
||||
((node.parent.kind === SyntaxKind.ImportDeclaration || node.parent.kind === SyntaxKind.ExportDeclaration) &&
|
||||
(<ImportDeclaration>node.parent).moduleSpecifier === node)) {
|
||||
// import x = require("./mo/*gotToDefinitionHere*/d")
|
||||
if (isExternalModuleImportEqualsDeclaration(node.parent.parent) && getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) {
|
||||
return resolveExternalModuleName(node, <LiteralExpression>node);
|
||||
}
|
||||
if (isInJavaScriptFile(node) && isRequireCall(node.parent, /*checkArgumentIsStringLiteral*/ false)) {
|
||||
// External module name in an import declaration
|
||||
if ((node.parent.kind === SyntaxKind.ImportDeclaration || node.parent.kind === SyntaxKind.ExportDeclaration) && (<ImportDeclaration>node.parent).moduleSpecifier === node) {
|
||||
return resolveExternalModuleName(node, <LiteralExpression>node);
|
||||
}
|
||||
if ((isInJavaScriptFile(node) && isRequireCall(node.parent, /*checkArgumentIsStringLiteral*/ false)) ||
|
||||
isImportCall(node.parent)) {
|
||||
return resolveExternalModuleName(node, <LiteralExpression>node);
|
||||
}
|
||||
// falls through
|
||||
|
||||
@ -307,7 +307,7 @@ namespace ts.FindAllReferences.Core {
|
||||
case SyntaxKind.ExportDeclaration:
|
||||
return true;
|
||||
case SyntaxKind.CallExpression:
|
||||
return isRequireCall(node.parent as CallExpression, /*checkArgumentIsStringLiteral*/ false);
|
||||
return isRequireCall(node.parent as CallExpression, /*checkArgumentIsStringLiteral*/ false) || isImportCall(node.parent as CallExpression);
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
9
tests/cases/fourslash/findAllReferencesDynamicImport1.ts
Normal file
9
tests/cases/fourslash/findAllReferencesDynamicImport1.ts
Normal file
@ -0,0 +1,9 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
// @Filename: foo.ts
|
||||
//// export function foo() { return "foo"; }
|
||||
|
||||
//// import("[|./foo|]")
|
||||
//// var x = import("[|./foo|]")
|
||||
|
||||
verify.rangesReferenceEachOther();
|
||||
10
tests/cases/fourslash/goToDefinitionDynamicImport1.ts
Normal file
10
tests/cases/fourslash/goToDefinitionDynamicImport1.ts
Normal file
@ -0,0 +1,10 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
// @Filename: foo.ts
|
||||
//// /*Destination*/export function foo() { return "foo"; }
|
||||
|
||||
//// import("./f/*1*/oo")
|
||||
//// var x = import("./fo/*2*/o")
|
||||
|
||||
verify.goToDefinition("1", "Destination");
|
||||
verify.goToDefinition("2", "Destination");
|
||||
Loading…
x
Reference in New Issue
Block a user