Skip to content

Commit ebe7530

Browse files
sheetalkamatandrewbranch
authored andcommitted
Fix getSymbolAtLocation for importCall (microsoft#1587)
1 parent 191a76d commit ebe7530

File tree

201 files changed

+376
-1589
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

201 files changed

+376
-1589
lines changed

internal/checker/checker.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30272,7 +30272,7 @@ func (c *Checker) getSymbolAtLocation(node *ast.Node, ignoreErrors bool) *ast.Sy
3027230272
// 4). type A = import("./f/*gotToDefinitionHere*/oo")
3027330273
if (ast.IsExternalModuleImportEqualsDeclaration(grandParent) && ast.GetExternalModuleImportEqualsDeclarationExpression(grandParent) == node) ||
3027430274
((parent.Kind == ast.KindImportDeclaration || parent.Kind == ast.KindJSImportDeclaration || parent.Kind == ast.KindExportDeclaration) && ast.GetExternalModuleName(parent) == node) ||
30275-
ast.IsVariableDeclarationInitializedToRequire(grandParent) ||
30275+
ast.IsVariableDeclarationInitializedToRequire(grandParent) || ast.IsImportCall(parent) ||
3027630276
(ast.IsLiteralTypeNode(parent) && ast.IsLiteralImportTypeNode(grandParent) && grandParent.AsImportTypeNode().Argument == parent) {
3027730277
return c.resolveExternalModuleName(node, node, ignoreErrors)
3027830278
}

internal/fourslash/_scripts/failingTests.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ TestDoubleUnderscoreCompletions
168168
TestEditJsdocType
169169
TestExportDefaultClass
170170
TestExportDefaultFunction
171+
TestFindAllReferencesDynamicImport1
171172
TestFindAllReferencesTripleSlash
172173
TestFindAllReferencesUmdModuleAsGlobalConst
173174
TestFindAllRefsCommonJsRequire

internal/fourslash/tests/gen/findAllReferencesDynamicImport1_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99

1010
func TestFindAllReferencesDynamicImport1(t *testing.T) {
1111
t.Parallel()
12-
12+
t.Skip()
1313
defer testutil.RecoverAndFail(t, "Panic on fourslash test")
1414
const content = `// @Filename: foo.ts
1515
export function foo() { return "foo"; }

testdata/baselines/reference/fourslash/findAllRef/FindAllReferencesDynamicImport1.baseline.jsonc

Lines changed: 0 additions & 36 deletions
This file was deleted.
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
// === goToDefinition ===
22
// === /foo.ts ===
33

4-
// export function foo() { return "foo"; }
4+
// [|export function foo() { return "foo"; }
55
// import("./f/*GO TO DEFINITION*/oo")
6-
// var x = import("./foo")
6+
// var x = import("./foo")|]
77

88

99

1010

1111
// === goToDefinition ===
1212
// === /foo.ts ===
1313

14-
// export function foo() { return "foo"; }
14+
// [|export function foo() { return "foo"; }
1515
// import("./foo")
16-
// var x = import("./fo/*GO TO DEFINITION*/o")
16+
// var x = import("./fo/*GO TO DEFINITION*/o")|]

testdata/baselines/reference/submodule/compiler/declarationEmitDoesNotUseReexportedNamespaceAsLocal.symbols

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export function a() {}
88
export const x = add(import("./sub"));
99
>x : Symbol(x, Decl(index.ts, 0, 12))
1010
>add : Symbol(add, Decl(index.ts, 1, 27))
11+
>"./sub" : Symbol("sub", Decl(sub.ts, 0, 0))
1112

1213
export * as Q from "./sub";
1314
>Q : Symbol(Q, Decl(index.ts, 1, 6))

testdata/baselines/reference/submodule/compiler/declarationEmitDoesNotUseReexportedNamespaceAsLocal.symbols.diff

Lines changed: 0 additions & 10 deletions
This file was deleted.

testdata/baselines/reference/submodule/compiler/declarationEmitExportAliasVisibiilityMarking.symbols

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ export default (suit: Suit, rank: Rank) => ({suit, rank});
2828
export let lazyCard = () => import('./Card').then(a => a.default);
2929
>lazyCard : Symbol(lazyCard, Decl(index.ts, 0, 10))
3030
>import('./Card').then : Symbol(then, Decl(lib.es5.d.ts, --, --))
31+
>'./Card' : Symbol("Card", Decl(Card.ts, 0, 0))
3132
>then : Symbol(then, Decl(lib.es5.d.ts, --, --))
3233
>a : Symbol(a, Decl(index.ts, 0, 50))
3334
>a.default : Symbol(default, Decl(Card.ts, 0, 37))

testdata/baselines/reference/submodule/compiler/declarationEmitExportAliasVisibiilityMarking.symbols.diff

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
export let lazyCard = () => import('./Card').then(a => a.default);
66
>lazyCard : Symbol(lazyCard, Decl(index.ts, 0, 10))
77
->import('./Card').then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --))
8-
->'./Card' : Symbol("Card", Decl(Card.ts, 0, 0))
9-
->then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --))
108
+>import('./Card').then : Symbol(then, Decl(lib.es5.d.ts, --, --))
9+
>'./Card' : Symbol("Card", Decl(Card.ts, 0, 0))
10+
->then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --))
1111
+>then : Symbol(then, Decl(lib.es5.d.ts, --, --))
1212
>a : Symbol(a, Decl(index.ts, 0, 50))
1313
>a.default : Symbol(default, Decl(Card.ts, 0, 37))

testdata/baselines/reference/submodule/compiler/dynamicImportsDeclaration.symbols

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,14 @@ export const mod = await (async () => {
2424

2525
case 0:
2626
return await import("./case0.js");
27+
>"./case0.js" : Symbol("/case0", Decl(case0.ts, 0, 0))
28+
2729
case 1:
2830
return await import("./case1.js");
31+
>"./case1.js" : Symbol("/case1", Decl(case1.ts, 0, 0))
32+
2933
default:
3034
return await import("./caseFallback.js");
35+
>"./caseFallback.js" : Symbol("/caseFallback", Decl(caseFallback.ts, 0, 0))
3136
}
3237
})();

0 commit comments

Comments
 (0)