feat(ivy): produce contextual diagnostics in ngtsc mode (#25647)
TypeScript has a more modern diagnostic emit function which produces contextually annotated error information, using colors in the console to indicate where in the code the error occurs. This commit swiches ngtsc to use this format for diagnostics when emitting them after a failed compilation. PR Close #25647
This commit is contained in:
parent
38f624d7e3
commit
a469c2c412
|
@ -26,6 +26,7 @@ ts_library(
|
|||
deps = [
|
||||
"//packages/compiler",
|
||||
"//packages/compiler-cli/src/ngtsc/annotations",
|
||||
"//packages/compiler-cli/src/ngtsc/diagnostics",
|
||||
"//packages/compiler-cli/src/ngtsc/factories",
|
||||
"//packages/compiler-cli/src/ngtsc/metadata",
|
||||
"//packages/compiler-cli/src/ngtsc/transform",
|
||||
|
|
|
@ -12,6 +12,8 @@ import 'reflect-metadata';
|
|||
|
||||
import * as ts from 'typescript';
|
||||
import * as tsickle from 'tsickle';
|
||||
|
||||
import {replaceTsWithNgInErrors} from './ngtsc/diagnostics';
|
||||
import * as api from './transformers/api';
|
||||
import {GENERATED_FILES} from './transformers/util';
|
||||
|
||||
|
@ -160,7 +162,15 @@ function reportErrorsAndExit(
|
|||
getCanonicalFileName: fileName => fileName,
|
||||
getNewLine: () => ts.sys.newLine
|
||||
};
|
||||
consoleError(formatDiagnostics(errorsAndWarnings, formatHost));
|
||||
if (options && (options.enableIvy === true || options.enableIvy === 'ngtsc')) {
|
||||
const ngDiagnostics = errorsAndWarnings.filter(api.isNgDiagnostic);
|
||||
const tsDiagnostics = errorsAndWarnings.filter(api.isTsDiagnostic);
|
||||
consoleError(replaceTsWithNgInErrors(
|
||||
ts.formatDiagnosticsWithColorAndContext(tsDiagnostics, formatHost)));
|
||||
consoleError(formatDiagnostics(ngDiagnostics, formatHost));
|
||||
} else {
|
||||
consoleError(formatDiagnostics(errorsAndWarnings, formatHost));
|
||||
}
|
||||
}
|
||||
return exitCodeFromResult(allDiagnostics);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue