Skip to content

Commit c46de15

Browse files
the-destrohansl
authored andcommitted
fix(@ngtools/webpack): use tsconfig declaration flag to report decl errors (#3499)
1 parent 87b93e1 commit c46de15

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

packages/@ngtools/webpack/src/refactor.ts

+10-4
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,20 @@ export class TypeScriptFileRefactor {
4848
this._sourceString = new MagicString(this._sourceText);
4949
}
5050

51+
/**
52+
* Collates the diagnostic messages for the current source file
53+
*/
5154
getDiagnostics(): ts.Diagnostic[] {
5255
if (!this._program) {
5356
return [];
5457
}
55-
56-
return this._program.getSyntacticDiagnostics(this._sourceFile)
57-
.concat(this._program.getSemanticDiagnostics(this._sourceFile))
58-
.concat(this._program.getDeclarationDiagnostics(this._sourceFile));
58+
let diagnostics: ts.Diagnostic[] = this._program.getSyntacticDiagnostics(this._sourceFile)
59+
.concat(this._program.getSemanticDiagnostics(this._sourceFile));
60+
// only concat the declaration diagnostics if the tsconfig config sets it to true.
61+
if (this._program.getCompilerOptions().declaration == true) {
62+
diagnostics = diagnostics.concat(this._program.getDeclarationDiagnostics(this._sourceFile));
63+
}
64+
return diagnostics;
5965
}
6066

6167
/**

0 commit comments

Comments
 (0)