Skip to content

Commit 93551ab

Browse files
author
Andy
authored
Update test that import code fix doesn't use node_modules global import if classic resolution is set (#20453)
1 parent 272266f commit 93551ab

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

src/harness/fourslash.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2522,9 +2522,9 @@ Actual: ${stringify(fullActual)}`);
25222522
}
25232523

25242524
public verifyImportFixAtPosition(expectedTextArray: string[], errorCode?: number) {
2525-
const ranges = this.getRanges();
2526-
if (ranges.length === 0) {
2527-
this.raiseError("At least one range should be specified in the testfile.");
2525+
const ranges = this.getRanges().filter(r => r.fileName === this.activeFile.fileName);
2526+
if (ranges.length !== 1) {
2527+
this.raiseError("Exactly one range should be specified in the testfile.");
25282528
}
25292529

25302530
const codeFixes = this.getCodeFixActions(this.activeFile.fileName, errorCode);

tests/cases/fourslash/importNameCodeFixNewImportIndex_notForClassicResolution.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,21 @@
1212
////[|foo;|]
1313

1414
// @Filename: /c.ts
15-
////bar;
15+
////[|bar;|]
1616

1717
goTo.file("/a/index.ts");
1818

1919
goTo.file("/b.ts");
20+
// Explicitly imports from "./a/index" and not just from "./a"
2021
verify.importFixAtPosition([
2122
`import { foo } from "./a/index";
2223
2324
foo;`
2425
]);
2526

2627
goTo.file("/c.ts");
27-
// TODO: GH#20050 verify.not.codeFixAvailable();
28+
// Does not use a global import for node_modules
29+
verify.importFixAtPosition([
30+
`import { bar } from "./node_modules/x/index";
31+
32+
bar;`]);

0 commit comments

Comments
 (0)