Skip to content

Commit

Permalink
refactor(migrations): enable debug printing of compiler diagnostics (a…
Browse files Browse the repository at this point in the history
…ngular#58515)

This is useful for some migrations and eases debugging, so we are
building an environment-guarded debug print.

PR Close angular#58515
  • Loading branch information
devversion authored and pkozlowski-opensource committed Nov 6, 2024
1 parent 6338cb7 commit 121b340
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
} from '@angular/compiler-cli/src/ngtsc/file_system';
import {NgtscProgram} from '@angular/compiler-cli/src/ngtsc/program';
import {BaseProgramInfo} from '../program_info';
import ts from 'typescript';

/** Code of the error raised by TypeScript when a tsconfig doesn't match any files. */
const NO_INPUTS_ERROR_CODE = 18003;
Expand Down Expand Up @@ -54,12 +55,20 @@ export function createNgtscProgram(
// Avoid checking libraries to speed up migrations.
skipLibCheck: true,
skipDefaultLibCheck: true,
noEmit: true,
// Additional override options.
...optionOverrides,
},
tsHost,
);

// Expose an easy way to debug-print ng semantic diagnostics.
if (process.env['DEBUG_NG_SEMANTIC_DIAGNOSTICS'] === '1') {
console.error(
ts.formatDiagnosticsWithColorAndContext(ngtscProgram.getNgSemanticDiagnostics(), tsHost),
);
}

return {
ngCompiler: ngtscProgram.compiler,
program: ngtscProgram.getTsProgram(),
Expand Down

0 comments on commit 121b340

Please sign in to comment.