Skip to content

Commit f11f14b

Browse files
authored
Fix broken module resolution after large/rapid edits in nodenext (#46818)
* Fix broken module resolution after edits in nodenext * Move field copying to a better place I guess
1 parent 009dd48 commit f11f14b

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

src/compiler/program.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1577,6 +1577,7 @@ namespace ts {
15771577
newSourceFile.originalFileName = oldSourceFile.originalFileName;
15781578
newSourceFile.resolvedPath = oldSourceFile.resolvedPath;
15791579
newSourceFile.fileName = oldSourceFile.fileName;
1580+
newSourceFile.impliedNodeFormat = oldSourceFile.impliedNodeFormat;
15801581

15811582
const packageName = oldProgram.sourceFileToPackageName.get(oldSourceFile.path);
15821583
if (packageName !== undefined) {

src/harness/fourslashImpl.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -637,7 +637,8 @@ namespace FourSlash {
637637
ts.forEachKey(this.inputFiles, fileName => {
638638
if (!ts.isAnySupportedFileExtension(fileName)
639639
|| Harness.getConfigNameFromFileName(fileName)
640-
|| !ts.getAllowJSCompilerOption(this.getProgram().getCompilerOptions()) && !ts.resolutionExtensionIsTSOrJson(ts.extensionFromPath(fileName))
640+
// Can't get a Program in Server tests
641+
|| this.testType !== FourSlashTestType.Server && !ts.getAllowJSCompilerOption(this.getProgram().getCompilerOptions()) && !ts.resolutionExtensionIsTSOrJson(ts.extensionFromPath(fileName))
641642
|| ts.getBaseFileName(fileName) === "package.json") return;
642643
const errors = this.getDiagnostics(fileName).filter(e => e.category !== ts.DiagnosticCategory.Suggestion);
643644
if (errors.length) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/// <reference path="../fourslash.ts" />
2+
3+
// @Filename: /tsconfig.json
4+
//// { "compilerOptions": { "module": "nodenext" } }
5+
6+
// @Filename: /package.json
7+
//// { "name": "foo", "type": "module", "exports": { ".": "./main.js" } }
8+
9+
// @Filename: /main.ts
10+
//// export {};
11+
12+
// @Filename: /index.ts
13+
//// import {} from "foo";
14+
15+
goTo.file("/index.ts");
16+
verify.noErrors();
17+
18+
edit.paste(`\n"${"a".repeat(256)}";`);
19+
20+
verify.noErrors();

0 commit comments

Comments
 (0)