Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(compiler): switch to modern diagnostic formatting #34234

Closed
wants to merge 1 commit into from

Conversation

@alxhub
Copy link
Contributor

alxhub commented Dec 4, 2019

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.

@alxhub alxhub requested a review from angular/fw-compiler as a code owner Dec 4, 2019
@googlebot googlebot added the cla: yes label Dec 4, 2019
@alxhub alxhub requested a review from josephperrott Dec 4, 2019
Copy link
Member

josephperrott left a comment

LGTM

@alxhub alxhub force-pushed the alxhub:ngtsc/format-diags branch from 56af135 to 01df0fd Dec 4, 2019
@@ -963,7 +963,7 @@ describe('ng program', () => {
});
});

it('should report errors for ts and ng errors on emit with noEmitOnError=true', () => {
fit('should report errors for ts and ng errors on emit with noEmitOnError=true', () => {

This comment has been minimized.

Copy link
@alfaproject

alfaproject Dec 4, 2019

Contributor

Oops

@@ -105,7 +106,9 @@ describe('ngc transformer command-line', () => {
}`);

const exitCode = main(['-p', basePath], errorSpy);
expect(errorSpy).toHaveBeenCalledWith(
debugger;

This comment has been minimized.

Copy link
@gkalpak
@clydin

This comment has been minimized.

Copy link
Member

clydin commented Dec 5, 2019

This section can probably be simplified with this change as well:

if (options && options.enableIvy !== false) {
const ngDiagnostics = diagnostics.filter(api.isNgDiagnostic);
const tsDiagnostics = diagnostics.filter(api.isTsDiagnostic);
consoleError(replaceTsWithNgInErrors(
ts.formatDiagnosticsWithColorAndContext(tsDiagnostics, formatHost)));
consoleError(formatDiagnostics(ngDiagnostics, formatHost));
} else {
consoleError(formatDiagnostics(diagnostics, formatHost));
}

@ngbot ngbot bot added this to the needsTriage milestone Dec 5, 2019
@alxhub alxhub force-pushed the alxhub:ngtsc/format-diags branch 2 times, most recently from 68f35ce to 0aa1ea5 Dec 6, 2019
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`.
@alxhub alxhub force-pushed the alxhub:ngtsc/format-diags branch from 0aa1ea5 to 65de832 Dec 7, 2019
@alxhub

This comment has been minimized.

Copy link
Contributor Author

alxhub commented Dec 7, 2019

AndrewKushnir added a commit that referenced this pull request Dec 9, 2019
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
josephperrott added a commit to josephperrott/angular that referenced this pull request Dec 11, 2019
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 angular#34234
@angular-automatic-lock-bot

This comment has been minimized.

Copy link

angular-automatic-lock-bot bot commented Jan 9, 2020

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Jan 9, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.