Skip to content

Commit 78fd963

Browse files
committed
Add hasErrors property to tsbuildInfo so we can build again if there are errors
Also add roots property to non incremental build to check if root files went missing
1 parent 0b0886f commit 78fd963

File tree

186 files changed

+5452
-2892
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

186 files changed

+5452
-2892
lines changed

src/compiler/builder.ts

+85-91
Large diffs are not rendered by default.

src/compiler/builderPublic.ts

-5
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import {
1313
Program,
1414
ProjectReference,
1515
ReusableBuilderProgramState,
16-
SavedBuildProgramEmitState,
1716
SourceFile,
1817
WriteFileCallback,
1918
} from "./_namespaces/ts.js";
@@ -48,10 +47,6 @@ export interface BuilderProgram {
4847
/** @internal */
4948
state: ReusableBuilderProgramState;
5049
/** @internal */
51-
saveEmitState(): SavedBuildProgramEmitState;
52-
/** @internal */
53-
restoreEmitState(saved: SavedBuildProgramEmitState): void;
54-
/** @internal */
5550
hasChangedEmitSignature?(): boolean;
5651
/**
5752
* Returns current program

src/compiler/diagnosticMessages.json

+8-4
Original file line numberDiff line numberDiff line change
@@ -4365,10 +4365,6 @@
43654365
"category": "Error",
43664366
"code": 5012
43674367
},
4368-
"Failed to parse file '{0}': {1}.": {
4369-
"category": "Error",
4370-
"code": 5014
4371-
},
43724368
"Unknown compiler option '{0}'.": {
43734369
"category": "Error",
43744370
"code": 5023
@@ -5898,6 +5894,14 @@
58985894
"category": "Message",
58995895
"code": 6418
59005896
},
5897+
"Project '{0}' is out of date because buildinfo file '{1}' indicates that program needs to report errors.": {
5898+
"category": "Message",
5899+
"code": 6419
5900+
},
5901+
"Project '{0}' is out of date because {1}.": {
5902+
"category": "Message",
5903+
"code": 6420
5904+
},
59015905

59025906
"The expected type comes from property '{0}' which is declared here on type '{1}'": {
59035907
"category": "Message",

src/compiler/emitter.ts

+6-3
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,7 @@ import {
420420
WithStatement,
421421
writeCommentRange,
422422
writeFile,
423+
WriteFileCallbackData,
423424
YieldExpression,
424425
} from "./_namespaces/ts.js";
425426
import * as performance from "./_namespaces/ts.performance.js";
@@ -923,7 +924,7 @@ export function emitFiles(
923924
isEmitNotificationEnabled: declarationTransform.isEmitNotificationEnabled,
924925
substituteNode: declarationTransform.substituteNode,
925926
});
926-
printSourceFileOrBundle(
927+
const dtsWritten = printSourceFileOrBundle(
927928
declarationFilePath,
928929
declarationMapPath,
929930
declarationTransform,
@@ -937,7 +938,7 @@ export function emitFiles(
937938
},
938939
);
939940
if (emittedFilesList) {
940-
emittedFilesList.push(declarationFilePath);
941+
if (dtsWritten) emittedFilesList.push(declarationFilePath);
941942
if (declarationMapPath) {
942943
emittedFilesList.push(declarationMapPath);
943944
}
@@ -1027,10 +1028,12 @@ export function emitFiles(
10271028

10281029
// Write the output file
10291030
const text = writer.getText();
1030-
writeFile(host, emitterDiagnostics, jsFilePath, text, !!compilerOptions.emitBOM, sourceFiles, { sourceMapUrlPos, diagnostics: transform.diagnostics });
1031+
const data: WriteFileCallbackData = { sourceMapUrlPos, diagnostics: transform.diagnostics };
1032+
writeFile(host, emitterDiagnostics, jsFilePath, text, !!compilerOptions.emitBOM, sourceFiles, data);
10311033

10321034
// Reset state
10331035
writer.clear();
1036+
return !data.skippedDtsWrite;
10341037
}
10351038

10361039
interface SourceMapOptions {

src/compiler/tsbuild.ts

+10-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ export enum UpToDateStatusType {
2020
ErrorReadingFile,
2121
OutOfDateWithSelf,
2222
OutOfDateWithUpstream,
23-
OutOfDateBuildInfo,
23+
OutOfDateBuildInfoWithPendingEmit,
24+
OutOfDateBuildInfoWithErrors,
2425
OutOfDateOptions,
2526
OutOfDateRoots,
2627
UpstreamOutOfDate,
@@ -76,7 +77,10 @@ export namespace Status {
7677
* We track what the newest input file is.
7778
*/
7879
export interface UpToDate {
79-
type: UpToDateStatusType.UpToDate | UpToDateStatusType.UpToDateWithUpstreamTypes | UpToDateStatusType.UpToDateWithInputFileText;
80+
type:
81+
| UpToDateStatusType.UpToDate
82+
| UpToDateStatusType.UpToDateWithUpstreamTypes
83+
| UpToDateStatusType.UpToDateWithInputFileText;
8084
newestInputFileTime?: Date;
8185
newestInputFileName?: string;
8286
oldestOutputFileName: string;
@@ -112,7 +116,10 @@ export namespace Status {
112116
* Buildinfo indicates that build is out of date
113117
*/
114118
export interface OutOfDateBuildInfo {
115-
type: UpToDateStatusType.OutOfDateBuildInfo | UpToDateStatusType.OutOfDateOptions;
119+
type:
120+
| UpToDateStatusType.OutOfDateBuildInfoWithPendingEmit
121+
| UpToDateStatusType.OutOfDateBuildInfoWithErrors
122+
| UpToDateStatusType.OutOfDateOptions;
116123
buildInfoFile: string;
117124
}
118125

0 commit comments

Comments
 (0)