mirror of
https://github.com/angular/angular
synced 2026-05-24 09:28:37 +00:00
refactor(migrations): enable debug printing of compiler diagnostics (#58515)
This is useful for some migrations and eases debugging, so we are building an environment-guarded debug print. PR Close #58515
This commit is contained in:
parent
d4d76ead80
commit
4a0dc3c712
1 changed files with 9 additions and 0 deletions
|
|
@ -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;
|
||||
|
|
@ -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(),
|
||||
|
|
|
|||
Loading…
Reference in a new issue