diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 85d2e51985a..b051c0f5bcc 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -1031,6 +1031,7 @@ namespace ts { function getDeclarationDiagnostics(sourceFile: SourceFile, cancellationToken: CancellationToken): Diagnostic[] { const options = program.getCompilerOptions(); + // collect diagnostics from the program only once if either no source file was specified or out/outFile is set (bundled emit) if (!sourceFile || options.out || options.outFile) { return getDeclarationDiagnosticsWorker(sourceFile, cancellationToken); }