From 237fcfe961ea24a13dbadd334959291419bb237b Mon Sep 17 00:00:00 2001 From: Nik R Date: Fri, 9 Dec 2016 10:02:25 -0800 Subject: [PATCH 1/2] Add conditional to ignore declaration errors --- packages/@ngtools/webpack/src/refactor.ts | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/packages/@ngtools/webpack/src/refactor.ts b/packages/@ngtools/webpack/src/refactor.ts index d38444d75c6f..637d06bece3b 100644 --- a/packages/@ngtools/webpack/src/refactor.ts +++ b/packages/@ngtools/webpack/src/refactor.ts @@ -48,14 +48,22 @@ 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 []; } + 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; + - return this._program.getSyntacticDiagnostics(this._sourceFile) - .concat(this._program.getSemanticDiagnostics(this._sourceFile)) - .concat(this._program.getDeclarationDiagnostics(this._sourceFile)); } /** From a2b8b3655e8276a6c51be98acd58116e7bf037e2 Mon Sep 17 00:00:00 2001 From: Nik R Date: Fri, 9 Dec 2016 10:19:57 -0800 Subject: [PATCH 2/2] Linting --- packages/@ngtools/webpack/src/refactor.ts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/packages/@ngtools/webpack/src/refactor.ts b/packages/@ngtools/webpack/src/refactor.ts index 637d06bece3b..9ae55c401fd6 100644 --- a/packages/@ngtools/webpack/src/refactor.ts +++ b/packages/@ngtools/webpack/src/refactor.ts @@ -55,15 +55,13 @@ export class TypeScriptFileRefactor { if (!this._program) { return []; } - let diagnostics:ts.Diagnostic[] = this._program.getSyntacticDiagnostics(this._sourceFile) - .concat(this._program.getSemanticDiagnostics(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){ + if (this._program.getCompilerOptions().declaration == true) { diagnostics = diagnostics.concat(this._program.getDeclarationDiagnostics(this._sourceFile)); } return diagnostics; - - } /**