Skip to content

Commit acedf3c

Browse files
committed
Do not emit files if noEmit is specified
Handles microsoft#5799
1 parent 78ba4b2 commit acedf3c

4 files changed

Lines changed: 3 additions & 28 deletions

File tree

src/compiler/declarationEmitter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1675,7 +1675,7 @@ namespace ts {
16751675
/* @internal */
16761676
export function writeDeclarationFile(declarationFilePath: string, sourceFiles: SourceFile[], isBundledEmit: boolean, host: EmitHost, resolver: EmitResolver, emitterDiagnostics: DiagnosticCollection) {
16771677
const emitDeclarationResult = emitDeclarations(host, resolver, emitterDiagnostics, declarationFilePath, sourceFiles, isBundledEmit);
1678-
const emitSkipped = emitDeclarationResult.reportedDeclarationError || host.isEmitBlocked(declarationFilePath);
1678+
const emitSkipped = emitDeclarationResult.reportedDeclarationError || host.isEmitBlocked(declarationFilePath) || host.getCompilerOptions().noEmit;
16791679
if (!emitSkipped) {
16801680
const declarationOutput = emitDeclarationResult.referencePathsOutput
16811681
+ getDeclarationOutput(emitDeclarationResult.synchronousDeclarationOutput, emitDeclarationResult.moduleElementDeclarationEmitInfo);

src/compiler/emitter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8221,7 +8221,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
82218221
function emitFile({ jsFilePath, sourceMapFilePath, declarationFilePath}: { jsFilePath: string, sourceMapFilePath: string, declarationFilePath: string },
82228222
sourceFiles: SourceFile[], isBundledEmit: boolean) {
82238223
// Make sure not to write js File and source map file if any of them cannot be written
8224-
if (!host.isEmitBlocked(jsFilePath)) {
8224+
if (!host.isEmitBlocked(jsFilePath) && !compilerOptions.noEmit) {
82258225
emitJavaScript(jsFilePath, sourceMapFilePath, sourceFiles, isBundledEmit);
82268226
}
82278227
else {

src/harness/compilerRunner.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ class CompilerBaselineRunner extends RunnerBase {
142142

143143
it("Correct JS output for " + fileName, () => {
144144
if (hasNonDtsFiles && this.emit) {
145-
if (result.files.length === 0 && result.errors.length === 0) {
145+
if (!options.noEmit && result.files.length === 0 && result.errors.length === 0) {
146146
throw new Error("Expected at least one js file to be emitted or at least one error to be created.");
147147
}
148148

tests/baselines/reference/jsFileCompilationBindErrors.js

Lines changed: 0 additions & 25 deletions
This file was deleted.

0 commit comments

Comments
 (0)