Skip to content

Commit 8ca12a6

Browse files
committed
Fix broken module resolution after edits in nodenext
1 parent 7615547 commit 8ca12a6

File tree

3 files changed

+25
-2
lines changed

3 files changed

+25
-2
lines changed

src/harness/fourslashImpl.ts

Lines changed: 2 additions & 1 deletion
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) {

src/services/services.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1124,7 +1124,9 @@ namespace ts {
11241124
}
11251125

11261126
// Otherwise, just create a new source file.
1127-
return createLanguageServiceSourceFile(sourceFile.fileName, scriptSnapshot, sourceFile.languageVersion, version, /*setNodeParents*/ true, sourceFile.scriptKind);
1127+
const newSourceFile = createLanguageServiceSourceFile(sourceFile.fileName, scriptSnapshot, sourceFile.languageVersion, version, /*setNodeParents*/ true, sourceFile.scriptKind);
1128+
newSourceFile.impliedNodeFormat = sourceFile.impliedNodeFormat;
1129+
return newSourceFile;
11281130
}
11291131

11301132
const NoopCancellationToken: CancellationToken = {
Lines changed: 20 additions & 0 deletions
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)