Skip to content

Commit 121b340

Browse files
devversionpkozlowski-opensource
authored andcommitted
refactor(migrations): enable debug printing of compiler diagnostics (angular#58515)
This is useful for some migrations and eases debugging, so we are building an environment-guarded debug print. PR Close angular#58515
1 parent 6338cb7 commit 121b340

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

packages/core/schematics/utils/tsurge/helpers/ngtsc_program.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {
1616
} from '@angular/compiler-cli/src/ngtsc/file_system';
1717
import {NgtscProgram} from '@angular/compiler-cli/src/ngtsc/program';
1818
import {BaseProgramInfo} from '../program_info';
19+
import ts from 'typescript';
1920

2021
/** Code of the error raised by TypeScript when a tsconfig doesn't match any files. */
2122
const NO_INPUTS_ERROR_CODE = 18003;
@@ -54,12 +55,20 @@ export function createNgtscProgram(
5455
// Avoid checking libraries to speed up migrations.
5556
skipLibCheck: true,
5657
skipDefaultLibCheck: true,
58+
noEmit: true,
5759
// Additional override options.
5860
...optionOverrides,
5961
},
6062
tsHost,
6163
);
6264

65+
// Expose an easy way to debug-print ng semantic diagnostics.
66+
if (process.env['DEBUG_NG_SEMANTIC_DIAGNOSTICS'] === '1') {
67+
console.error(
68+
ts.formatDiagnosticsWithColorAndContext(ngtscProgram.getNgSemanticDiagnostics(), tsHost),
69+
);
70+
}
71+
6372
return {
6473
ngCompiler: ngtscProgram.compiler,
6574
program: ngtscProgram.getTsProgram(),

0 commit comments

Comments
 (0)