Skip to content

tsc -b removes silent noEmitOnError and emits files even if there are errors #58838

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
174 changes: 84 additions & 90 deletions src/compiler/builder.ts

Large diffs are not rendered by default.

5 changes: 0 additions & 5 deletions src/compiler/builderPublic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import {
Program,
ProjectReference,
ReusableBuilderProgramState,
SavedBuildProgramEmitState,
SourceFile,
WriteFileCallback,
} from "./_namespaces/ts.js";
Expand Down Expand Up @@ -48,10 +47,6 @@ export interface BuilderProgram {
/** @internal */
state: ReusableBuilderProgramState;
/** @internal */
saveEmitState(): SavedBuildProgramEmitState;
/** @internal */
restoreEmitState(saved: SavedBuildProgramEmitState): void;
/** @internal */
hasChangedEmitSignature?(): boolean;
/**
* Returns current program
Expand Down
12 changes: 8 additions & 4 deletions src/compiler/diagnosticMessages.json
Original file line number Diff line number Diff line change
Expand Up @@ -4365,10 +4365,6 @@
"category": "Error",
"code": 5012
},
"Failed to parse file '{0}': {1}.": {
"category": "Error",
"code": 5014
},
"Unknown compiler option '{0}'.": {
"category": "Error",
"code": 5023
Expand Down Expand Up @@ -5898,6 +5894,14 @@
"category": "Message",
"code": 6418
},
"Project '{0}' is out of date because buildinfo file '{1}' indicates that program needs to report errors.": {
"category": "Message",
"code": 6419
},
"Project '{0}' is out of date because {1}.": {
"category": "Message",
"code": 6420
},

"The expected type comes from property '{0}' which is declared here on type '{1}'": {
"category": "Message",
Expand Down
9 changes: 6 additions & 3 deletions src/compiler/emitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,7 @@ import {
WithStatement,
writeCommentRange,
writeFile,
WriteFileCallbackData,
YieldExpression,
} from "./_namespaces/ts.js";
import * as performance from "./_namespaces/ts.performance.js";
Expand Down Expand Up @@ -923,7 +924,7 @@ export function emitFiles(
isEmitNotificationEnabled: declarationTransform.isEmitNotificationEnabled,
substituteNode: declarationTransform.substituteNode,
});
printSourceFileOrBundle(
const dtsWritten = printSourceFileOrBundle(
declarationFilePath,
declarationMapPath,
declarationTransform,
Expand All @@ -937,7 +938,7 @@ export function emitFiles(
},
);
if (emittedFilesList) {
emittedFilesList.push(declarationFilePath);
if (dtsWritten) emittedFilesList.push(declarationFilePath);
if (declarationMapPath) {
emittedFilesList.push(declarationMapPath);
}
Expand Down Expand Up @@ -1027,10 +1028,12 @@ export function emitFiles(

// Write the output file
const text = writer.getText();
writeFile(host, emitterDiagnostics, jsFilePath, text, !!compilerOptions.emitBOM, sourceFiles, { sourceMapUrlPos, diagnostics: transform.diagnostics });
const data: WriteFileCallbackData = { sourceMapUrlPos, diagnostics: transform.diagnostics };
writeFile(host, emitterDiagnostics, jsFilePath, text, !!compilerOptions.emitBOM, sourceFiles, data);

// Reset state
writer.clear();
return !data.skippedDtsWrite;
}

interface SourceMapOptions {
Expand Down
13 changes: 10 additions & 3 deletions src/compiler/tsbuild.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ export enum UpToDateStatusType {
ErrorReadingFile,
OutOfDateWithSelf,
OutOfDateWithUpstream,
OutOfDateBuildInfo,
OutOfDateBuildInfoWithPendingEmit,
OutOfDateBuildInfoWithErrors,
OutOfDateOptions,
OutOfDateRoots,
UpstreamOutOfDate,
Expand Down Expand Up @@ -76,7 +77,10 @@ export namespace Status {
* We track what the newest input file is.
*/
export interface UpToDate {
type: UpToDateStatusType.UpToDate | UpToDateStatusType.UpToDateWithUpstreamTypes | UpToDateStatusType.UpToDateWithInputFileText;
type:
| UpToDateStatusType.UpToDate
| UpToDateStatusType.UpToDateWithUpstreamTypes
| UpToDateStatusType.UpToDateWithInputFileText;
newestInputFileTime?: Date;
newestInputFileName?: string;
oldestOutputFileName: string;
Expand Down Expand Up @@ -112,7 +116,10 @@ export namespace Status {
* Buildinfo indicates that build is out of date
*/
export interface OutOfDateBuildInfo {
type: UpToDateStatusType.OutOfDateBuildInfo | UpToDateStatusType.OutOfDateOptions;
type:
| UpToDateStatusType.OutOfDateBuildInfoWithPendingEmit
| UpToDateStatusType.OutOfDateBuildInfoWithErrors
| UpToDateStatusType.OutOfDateOptions;
buildInfoFile: string;
}

Expand Down
Loading