-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Add formatDiagnostics utility #9689
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
Conversation
Background: we find that in every program where we type-check, we make a copy of this function to print the diagnostics that several TS apis return. |
cc @evmar |
thanks! |
i am amusing you want this in TS 2.0, if so can you port this to release-2.0 as well. either ways it should be in the nightly today. |
We actually have this function (or one very like it) in a few places inside our test harness, too. We should consolidate. |
I was saying to Alex that we'd also like to be able to get the pretty On Wed, Jul 13, 2016 at 12:32 PM, Wesley Wigham notifications@github.com
|
} | ||
|
||
const category = DiagnosticCategory[diagnostic.category].toLowerCase(); | ||
output += `${ category } TS${ diagnostic.code }: ${ flattenDiagnosticMessageText(diagnostic.messageText, sys.newLine) }${ sys.newLine }`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
using sys.newLine
is incorrect here since it can be used in environments where sys
is not defined. instead it should use host.newLine()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That was an existing bug in tsc.ts
, then. Other code nearby uses sys
as well. But I think your point is that this utility is likely useful in new contexts, not just current usage sites.
I'll send another PR to change it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tsc.ts
is only ever used in environments where sys
is defined (since it is the command line entry point for node's tsc.js and chakrahost's tsc.exe). utilities
, however, is not.
Discussed with @mhegazy on slack here: https://angular-team.slack.com/archives/typescript/p1454534510000080