Revert the change to block declaration emit in case of syntax or semantic errors

This commit is contained in:
Sheetal Nandi
2015-10-28 16:52:05 -07:00
parent 0c3c7f1a1b
commit fdb7a3e452
5 changed files with 4 additions and 40 deletions

View File

@@ -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)) {

View File

@@ -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);

View File

@@ -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;

View File

@@ -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).

View File

@@ -40,7 +40,6 @@ namespace ts {
getNewLine(): string;
isEmitBlocked(emitFileName: string): boolean;
isDeclarationEmitBlocked(emitFileName: string, sourceFile?: SourceFile): boolean;
writeFile: WriteFileCallback;
}