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
This commit is contained in:
parent
009dd487a6
commit
f11f14baba
|
@ -1577,6 +1577,7 @@ namespace ts {
|
|||
newSourceFile.originalFileName = oldSourceFile.originalFileName;
|
||||
newSourceFile.resolvedPath = oldSourceFile.resolvedPath;
|
||||
newSourceFile.fileName = oldSourceFile.fileName;
|
||||
newSourceFile.impliedNodeFormat = oldSourceFile.impliedNodeFormat;
|
||||
|
||||
const packageName = oldProgram.sourceFileToPackageName.get(oldSourceFile.path);
|
||||
if (packageName !== undefined) {
|
||||
|
|
|
@ -637,7 +637,8 @@ namespace FourSlash {
|
|||
ts.forEachKey(this.inputFiles, fileName => {
|
||||
if (!ts.isAnySupportedFileExtension(fileName)
|
||||
|| Harness.getConfigNameFromFileName(fileName)
|
||||
|| !ts.getAllowJSCompilerOption(this.getProgram().getCompilerOptions()) && !ts.resolutionExtensionIsTSOrJson(ts.extensionFromPath(fileName))
|
||||
// Can't get a Program in Server tests
|
||||
|| this.testType !== FourSlashTestType.Server && !ts.getAllowJSCompilerOption(this.getProgram().getCompilerOptions()) && !ts.resolutionExtensionIsTSOrJson(ts.extensionFromPath(fileName))
|
||||
|| ts.getBaseFileName(fileName) === "package.json") return;
|
||||
const errors = this.getDiagnostics(fileName).filter(e => e.category !== ts.DiagnosticCategory.Suggestion);
|
||||
if (errors.length) {
|
||||
|
|
20
tests/cases/fourslash/server/impliedNodeFormat.ts
Normal file
20
tests/cases/fourslash/server/impliedNodeFormat.ts
Normal file
|
@ -0,0 +1,20 @@
|
|||
/// <reference path="../fourslash.ts" />
|
||||
|
||||
// @Filename: /tsconfig.json
|
||||
//// { "compilerOptions": { "module": "nodenext" } }
|
||||
|
||||
// @Filename: /package.json
|
||||
//// { "name": "foo", "type": "module", "exports": { ".": "./main.js" } }
|
||||
|
||||
// @Filename: /main.ts
|
||||
//// export {};
|
||||
|
||||
// @Filename: /index.ts
|
||||
//// import {} from "foo";
|
||||
|
||||
goTo.file("/index.ts");
|
||||
verify.noErrors();
|
||||
|
||||
edit.paste(`\n"${"a".repeat(256)}";`);
|
||||
|
||||
verify.noErrors();
|
Loading…
Reference in a new issue