diff --git a/packages/compiler-cli/BUILD.bazel b/packages/compiler-cli/BUILD.bazel index 484a2f6303..d88a524840 100644 --- a/packages/compiler-cli/BUILD.bazel +++ b/packages/compiler-cli/BUILD.bazel @@ -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", diff --git a/packages/compiler-cli/src/main.ts b/packages/compiler-cli/src/main.ts index 4210b715f1..f7c29cfa4f 100644 --- a/packages/compiler-cli/src/main.ts +++ b/packages/compiler-cli/src/main.ts @@ -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); }