fix(compiler): switch to modern diagnostic formatting (#34234)
The compiler exports a `formatDiagnostics` function which consumers can use to print both ts and ng diagnostics. However, this function was previously using the "old" style TypeScript diagnostics, as opposed to the modern diagnostic printer which uses terminal colors and prints additional context information. This commit updates `formatDiagnostics` to use the modern formatter, plus to update Ivy's negative error codes to Angular 'NG' errors. The Angular CLI needs a little more work to use this function for printing TS diagnostics, but this commit alone should fix Bazel builds as ngc-wrapped goes through `formatDiagnostics`. PR Close #34234
This commit is contained in:

committed by
Andrew Kushnir

parent
13c2fad240
commit
9fa2c398e7
@ -171,3 +171,9 @@ export function expectNoDiagnosticsInProgram(options: ng.CompilerOptions, p: ng.
|
||||
export function normalizeSeparators(path: string): string {
|
||||
return path.replace(/\\/g, '/');
|
||||
}
|
||||
|
||||
const STRIP_ANSI = /\x1B\x5B\d+m/g;
|
||||
|
||||
export function stripAnsi(diags: string): string {
|
||||
return diags.replace(STRIP_ANSI, '');
|
||||
}
|
||||
|
Reference in New Issue
Block a user