From fdb7a3e452299dbc7159b9c4908d81a6b097b1ea Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Wed, 28 Oct 2015 16:52:05 -0700 Subject: [PATCH] Revert the change to block declaration emit in case of syntax or semantic errors --- src/compiler/core.ts | 2 +- src/compiler/declarationEmitter.ts | 2 +- src/compiler/program.ts | 38 ++---------------------------- src/compiler/types.ts | 1 - src/compiler/utilities.ts | 1 - 5 files changed, 4 insertions(+), 40 deletions(-) diff --git a/src/compiler/core.ts b/src/compiler/core.ts index 018f3022191..18b7425e02d 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -747,7 +747,7 @@ namespace ts { return false; } - export const extensionsToRemove = [".d.ts", ".ts", ".js", ".tsx", ".jsx"]; + const extensionsToRemove = [".d.ts", ".ts", ".js", ".tsx", ".jsx"]; export function removeFileExtension(path: string): string { for (let ext of extensionsToRemove) { if (fileExtensionIs(path, ext)) { diff --git a/src/compiler/declarationEmitter.ts b/src/compiler/declarationEmitter.ts index 86c90ff6f1c..eb329c67b0b 100644 --- a/src/compiler/declarationEmitter.ts +++ b/src/compiler/declarationEmitter.ts @@ -1608,7 +1608,7 @@ namespace ts { /* @internal */ export function writeDeclarationFile(declarationFilePath: string, sourceFile: SourceFile, host: EmitHost, resolver: EmitResolver, diagnostics: Diagnostic[]) { let emitDeclarationResult = emitDeclarations(host, resolver, diagnostics, declarationFilePath, sourceFile); - let emitSkipped = emitDeclarationResult.reportedDeclarationError || host.isDeclarationEmitBlocked(declarationFilePath, sourceFile); + let emitSkipped = emitDeclarationResult.reportedDeclarationError || host.isEmitBlocked(declarationFilePath); if (!emitSkipped) { let declarationOutput = emitDeclarationResult.referencePathsOutput + getDeclarationOutput(emitDeclarationResult.synchronousDeclarationOutput, emitDeclarationResult.moduleElementDeclarationEmitInfo); diff --git a/src/compiler/program.ts b/src/compiler/program.ts index db56f86e93b..acac0ca4e5f 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -394,7 +394,6 @@ namespace ts { getDiagnosticsProducingTypeChecker, getCommonSourceDirectory: () => commonSourceDirectory, emit, - isDeclarationEmitBlocked, getCurrentDirectory: () => host.getCurrentDirectory(), getNodeCount: () => getDiagnosticsProducingTypeChecker().getNodeCount(), getIdentifierCount: () => getDiagnosticsProducingTypeChecker().getIdentifierCount(), @@ -512,7 +511,7 @@ namespace ts { return true; } - function getEmitHost(writeFileCallback?: WriteFileCallback, cancellationToken?: CancellationToken): EmitHost { + function getEmitHost(writeFileCallback?: WriteFileCallback): EmitHost { return { getCanonicalFileName: fileName => host.getCanonicalFileName(fileName), getCommonSourceDirectory: program.getCommonSourceDirectory, @@ -524,7 +523,6 @@ namespace ts { writeFile: writeFileCallback || ( (fileName, data, writeByteOrderMark, onError) => host.writeFile(fileName, data, writeByteOrderMark, onError)), isEmitBlocked, - isDeclarationEmitBlocked: (emitFileName, sourceFile) => program.isDeclarationEmitBlocked(emitFileName, sourceFile, cancellationToken), }; } @@ -540,38 +538,6 @@ namespace ts { return runWithCancellationToken(() => emitWorker(this, sourceFile, writeFileCallback, cancellationToken)); } - function isDeclarationEmitBlocked(emitFileName: string, sourceFile?: SourceFile, cancellationToken?: CancellationToken): boolean { - if (isEmitBlocked(emitFileName)) { - return true; - } - - // Dont check for emit blocking options diagnostics because that check per emit file is already covered in isEmitBlocked - // We dont want to end up blocking declaration emit of one file because other file results in emit blocking error - if (getOptionsDiagnostics(cancellationToken, /*includeEmitBlockingDiagnostics*/false).length || - getGlobalDiagnostics().length) { - return true; - } - - if (sourceFile) { - // Do not generate declaration file for this if there are any errors in this file or any of the declaration files - return hasSyntaxOrSemanticDiagnostics(sourceFile) || - forEach(files, sourceFile => isDeclarationFile(sourceFile) && hasSyntaxOrSemanticDiagnostics(sourceFile)); - } - - // Check if the bundled emit source files have errors - return forEach(files, sourceFile => { - // Check all the files that will be bundled together as well as all the included declaration files are error free - if (!isExternalModule(sourceFile)) { - return hasSyntaxOrSemanticDiagnostics(sourceFile); - } - }); - - function hasSyntaxOrSemanticDiagnostics(file: SourceFile) { - return !!getSyntacticDiagnostics(file, cancellationToken).length || - !!getSemanticDiagnostics(file, cancellationToken).length; - } - } - function isEmitBlocked(emitFileName: string): boolean { return hasProperty(hasEmitBlockingDiagnostics, emitFileName); } @@ -598,7 +564,7 @@ namespace ts { let emitResult = emitFiles( emitResolver, - getEmitHost(writeFileCallback, cancellationToken), + getEmitHost(writeFileCallback), sourceFile); emitTime += new Date().getTime() - start; diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 5d41a60526a..928524b2ac7 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -1358,7 +1358,6 @@ namespace ts { getTypeChecker(): TypeChecker; /* @internal */ getCommonSourceDirectory(): string; - /* @internal */ isDeclarationEmitBlocked(emitFileName: string, sourceFile?: SourceFile, cancellationToken?: CancellationToken): boolean; // For testing purposes only. Should not be used by any other consumers (including the // language service). diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 838ff097933..f9489a9ddac 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -40,7 +40,6 @@ namespace ts { getNewLine(): string; isEmitBlocked(emitFileName: string): boolean; - isDeclarationEmitBlocked(emitFileName: string, sourceFile?: SourceFile): boolean; writeFile: WriteFileCallback; }