mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-18 16:34:36 -05:00
Do not report all declarations in Program.emit, only declaration diagnostics
This commit is contained in:
@@ -609,9 +609,18 @@ namespace ts {
|
||||
// immediately bail out. Note that we pass 'undefined' for 'sourceFile' so that we
|
||||
// get any preEmit diagnostics, not just the ones
|
||||
if (options.noEmitOnError) {
|
||||
const preEmitDiagnostics = getPreEmitDiagnostics(program, /*sourceFile:*/ undefined, cancellationToken);
|
||||
if (preEmitDiagnostics.length > 0) {
|
||||
return { diagnostics: preEmitDiagnostics, sourceMaps: undefined, emitSkipped: true };
|
||||
const diagnostics = program.getOptionsDiagnostics(cancellationToken).concat(
|
||||
program.getSyntacticDiagnostics(sourceFile, cancellationToken),
|
||||
program.getGlobalDiagnostics(cancellationToken),
|
||||
program.getSemanticDiagnostics(sourceFile, cancellationToken));
|
||||
let declarationDiagnostics: Diagnostic[] = [];
|
||||
|
||||
if (diagnostics.length === 0 && program.getCompilerOptions().declaration) {
|
||||
declarationDiagnostics = program.getDeclarationDiagnostics(/*sourceFile*/ undefined, cancellationToken);
|
||||
}
|
||||
|
||||
if (diagnostics.length > 0 || declarationDiagnostics.length > 0) {
|
||||
return { diagnostics: declarationDiagnostics, sourceMaps: undefined, emitSkipped: true };
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user