mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-25 05:29:07 -05:00
Revert the change to block declaration emit in case of syntax or semantic errors
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user