-
Notifications
You must be signed in to change notification settings - Fork 12.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Handle seenEmittedFiles which was not being set when emit of a file w…
…as complete (#33145) * Add test that fails because file is written multiple times Reported from #33061 * Handle seenEmittedFiles which was not being set when emit of a file was complete. It was issue only when errors are reported before emitting (which puts the files into pendingEmit that needs to check only in seenEmittedFiles) If emit happens before semantic diagnostics query this issue is not repro, because the affected files come into play and those are being set correctly Fixes #31398 * make baselining source map optional * Handle emitDeclarationOnly in --build scenario * Ensure we are using d.ts emit as signature even when --declarationMap is on (map files are emitted before d.ts) * Move module specifiers to verifyTsBuildOutput * implement create Hash to be default hashing plus data so we can verify it easily in baseline * Remove failing baseline * Accept correct baseline name
- Loading branch information
1 parent
5ea4257
commit 79bcb3d
Showing
46 changed files
with
1,571 additions
and
676 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
109 changes: 109 additions & 0 deletions
109
src/testRunner/unittests/tsbuild/emitDeclarationOnly.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
namespace ts { | ||
describe("unittests:: tsbuild:: on project with emitDeclarationOnly set to true", () => { | ||
let projFs: vfs.FileSystem; | ||
const { time, tick } = getTime(); | ||
before(() => { | ||
projFs = loadProjectFromDisk("tests/projects/emitDeclarationOnly", time); | ||
}); | ||
after(() => { | ||
projFs = undefined!; | ||
}); | ||
|
||
function verifyEmitDeclarationOnly(disableMap?: true) { | ||
verifyTsbuildOutput({ | ||
scenario: `only dts output in circular import project with emitDeclarationOnly${disableMap ? "" : " and declarationMap"}`, | ||
projFs: () => projFs, | ||
time, | ||
tick, | ||
proj: "emitDeclarationOnly", | ||
rootNames: ["/src"], | ||
lastProjectOutput: `/src/lib/index.d.ts`, | ||
outputFiles: [ | ||
"/src/lib/a.d.ts", | ||
"/src/lib/b.d.ts", | ||
"/src/lib/c.d.ts", | ||
"/src/lib/index.d.ts", | ||
"/src/tsconfig.tsbuildinfo", | ||
...(disableMap ? emptyArray : [ | ||
"/src/lib/a.d.ts.map", | ||
"/src/lib/b.d.ts.map", | ||
"/src/lib/c.d.ts.map", | ||
"/src/lib/index.d.ts.map" | ||
]) | ||
], | ||
initialBuild: { | ||
modifyFs: disableMap ? | ||
(fs => replaceText(fs, "/src/tsconfig.json", `"declarationMap": true,`, "")) : | ||
noop, | ||
expectedDiagnostics: [ | ||
getExpectedDiagnosticForProjectsInBuild("src/tsconfig.json"), | ||
[Diagnostics.Project_0_is_out_of_date_because_output_file_1_does_not_exist, "src/tsconfig.json", "src/lib/a.d.ts"], | ||
[Diagnostics.Building_project_0, "/src/tsconfig.json"] | ||
] | ||
}, | ||
incrementalDtsChangedBuild: { | ||
modifyFs: fs => replaceText(fs, "/src/src/a.ts", "b: B;", "b: B; foo: any;"), | ||
expectedDiagnostics: [ | ||
getExpectedDiagnosticForProjectsInBuild("src/tsconfig.json"), | ||
[Diagnostics.Project_0_is_out_of_date_because_oldest_output_1_is_older_than_newest_input_2, "src/tsconfig.json", "src/lib/a.d.ts", "src/src/a.ts"], | ||
[Diagnostics.Building_project_0, "/src/tsconfig.json"] | ||
] | ||
}, | ||
baselineOnly: true, | ||
verifyDiagnostics: true | ||
}); | ||
} | ||
verifyEmitDeclarationOnly(); | ||
verifyEmitDeclarationOnly(/*disableMap*/ true); | ||
|
||
verifyTsbuildOutput({ | ||
scenario: `only dts output in non circular imports project with emitDeclarationOnly`, | ||
projFs: () => projFs, | ||
time, | ||
tick, | ||
proj: "emitDeclarationOnly", | ||
rootNames: ["/src"], | ||
lastProjectOutput: `/src/lib/a.d.ts`, | ||
outputFiles: [ | ||
"/src/lib/a.d.ts", | ||
"/src/lib/b.d.ts", | ||
"/src/lib/c.d.ts", | ||
"/src/tsconfig.tsbuildinfo", | ||
"/src/lib/a.d.ts.map", | ||
"/src/lib/b.d.ts.map", | ||
"/src/lib/c.d.ts.map", | ||
], | ||
initialBuild: { | ||
modifyFs: fs => { | ||
fs.rimrafSync("/src/src/index.ts"); | ||
replaceText(fs, "/src/src/a.ts", `import { B } from "./b";`, `export class B { prop = "hello"; }`); | ||
}, | ||
expectedDiagnostics: [ | ||
getExpectedDiagnosticForProjectsInBuild("src/tsconfig.json"), | ||
[Diagnostics.Project_0_is_out_of_date_because_output_file_1_does_not_exist, "src/tsconfig.json", "src/lib/a.d.ts"], | ||
[Diagnostics.Building_project_0, "/src/tsconfig.json"] | ||
] | ||
}, | ||
incrementalDtsChangedBuild: { | ||
modifyFs: fs => replaceText(fs, "/src/src/a.ts", "b: B;", "b: B; foo: any;"), | ||
expectedDiagnostics: [ | ||
getExpectedDiagnosticForProjectsInBuild("src/tsconfig.json"), | ||
[Diagnostics.Project_0_is_out_of_date_because_oldest_output_1_is_older_than_newest_input_2, "src/tsconfig.json", "src/lib/a.d.ts", "src/src/a.ts"], | ||
[Diagnostics.Building_project_0, "/src/tsconfig.json"] | ||
] | ||
}, | ||
incrementalDtsUnchangedBuild: { | ||
modifyFs: fs => replaceText(fs, "/src/src/a.ts", "export interface A {", `class C { } | ||
export interface A {`), | ||
expectedDiagnostics: [ | ||
getExpectedDiagnosticForProjectsInBuild("src/tsconfig.json"), | ||
[Diagnostics.Project_0_is_out_of_date_because_oldest_output_1_is_older_than_newest_input_2, "src/tsconfig.json", "src/lib/a.d.ts", "src/src/a.ts"], | ||
[Diagnostics.Building_project_0, "/src/tsconfig.json"], | ||
[Diagnostics.Updating_unchanged_output_timestamps_of_project_0, "/src/tsconfig.json"] | ||
] | ||
}, | ||
baselineOnly: true, | ||
verifyDiagnostics: true | ||
}); | ||
}); | ||
} |
Oops, something went wrong.