Skip to content

Commit 2eef0c7

Browse files
committed
fix(@angular/build): skip semantic diagnostics for declaration files
Declaration files don't produce semantic or template diagnostics, so calling getSemanticDiagnostics() on them was just wasted work. Move the isDeclarationFile guard to before that call so .d.ts files are skipped entirely.
1 parent b44828c commit 2eef0c7

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

packages/angular/build/src/tools/angular/compilation/aot-compilation.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@ export class AotCompilation extends AngularCompilation {
234234

235235
const syntactic = modes & DiagnosticModes.Syntactic;
236236
const semantic = modes & DiagnosticModes.Semantic;
237+
const skipLibCheck = typeScriptProgram.getCompilerOptions().skipLibCheck;
237238

238239
// Collect program level diagnostics
239240
if (modes & DiagnosticModes.Option) {
@@ -265,13 +266,19 @@ export class AotCompilation extends AngularCompilation {
265266
continue;
266267
}
267268

269+
// When skipLibCheck is enabled (the default), declaration files are not
270+
// type-checked, so getSemanticDiagnostics() would return nothing for them.
271+
if (sourceFile.isDeclarationFile && skipLibCheck) {
272+
continue;
273+
}
274+
268275
yield* profileSync(
269276
'NG_DIAGNOSTICS_SEMANTIC',
270277
() => typeScriptProgram.getSemanticDiagnostics(sourceFile),
271278
true,
272279
);
273280

274-
// Declaration files cannot have template diagnostics
281+
// Declaration files cannot have template diagnostics.
275282
if (sourceFile.isDeclarationFile) {
276283
continue;
277284
}

0 commit comments

Comments
 (0)