MCPcopy Create free account
hub / github.com/angular/angular / defaultGatherDiagnostics

Function defaultGatherDiagnostics

packages/compiler-cli/src/perform_compile.ts:392–426  ·  view source on GitHub ↗
(program: api.Program)

Source from the content-addressed store, hash-verified

390 }
391}
392export function defaultGatherDiagnostics(program: api.Program): ReadonlyArray<ts.Diagnostic> {
393 const allDiagnostics: Array<ts.Diagnostic> = [];
394
395 function checkDiagnostics(diags: ReadonlyArray<ts.Diagnostic> | undefined) {
396 if (diags) {
397 allDiagnostics.push(...diags);
398 return !hasErrors(diags);
399 }
400 return true;
401 }
402
403 let checkOtherDiagnostics = true;
404 // Check parameter diagnostics
405 checkOtherDiagnostics =
406 checkOtherDiagnostics &&
407 checkDiagnostics([...program.getTsOptionDiagnostics(), ...program.getNgOptionDiagnostics()]);
408
409 // Check syntactic diagnostics
410 checkOtherDiagnostics =
411 checkOtherDiagnostics && checkDiagnostics(program.getTsSyntacticDiagnostics());
412
413 // Check TypeScript semantic and Angular structure diagnostics
414 checkOtherDiagnostics =
415 checkOtherDiagnostics &&
416 checkDiagnostics([
417 ...program.getTsSemanticDiagnostics(),
418 ...program.getNgStructuralDiagnostics(),
419 ]);
420
421 // Check Angular semantic diagnostics
422 checkOtherDiagnostics =
423 checkOtherDiagnostics && checkDiagnostics(program.getNgSemanticDiagnostics());
424
425 return allDiagnostics;
426}
427
428function hasErrors(diags: ReadonlyArray<ts.Diagnostic>) {
429 return diags.some((d) => d.category === ts.DiagnosticCategory.Error);

Callers 1

driveDiagnosticsAsyncMethod · 0.85

Calls 7

checkDiagnosticsFunction · 0.85

Tested by

no test coverage detected