From c46de15ef8fe4bfbe565c1c2ebaf13f0257ff7c8 Mon Sep 17 00:00:00 2001 From: the-destro Date: Fri, 9 Dec 2016 10:59:31 -0800 Subject: [PATCH] fix(@ngtools/webpack): use tsconfig declaration flag to report decl errors (#3499) --- packages/@ngtools/webpack/src/refactor.ts | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/packages/@ngtools/webpack/src/refactor.ts b/packages/@ngtools/webpack/src/refactor.ts index d38444d75c6f..9ae55c401fd6 100644 --- a/packages/@ngtools/webpack/src/refactor.ts +++ b/packages/@ngtools/webpack/src/refactor.ts @@ -48,14 +48,20 @@ export class TypeScriptFileRefactor { this._sourceString = new MagicString(this._sourceText); } + /** + * Collates the diagnostic messages for the current source file + */ getDiagnostics(): ts.Diagnostic[] { if (!this._program) { return []; } - - return this._program.getSyntacticDiagnostics(this._sourceFile) - .concat(this._program.getSemanticDiagnostics(this._sourceFile)) - .concat(this._program.getDeclarationDiagnostics(this._sourceFile)); + let diagnostics: ts.Diagnostic[] = this._program.getSyntacticDiagnostics(this._sourceFile) + .concat(this._program.getSemanticDiagnostics(this._sourceFile)); + // only concat the declaration diagnostics if the tsconfig config sets it to true. + if (this._program.getCompilerOptions().declaration == true) { + diagnostics = diagnostics.concat(this._program.getDeclarationDiagnostics(this._sourceFile)); + } + return diagnostics; } /**