Skip to content

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

Merged
merged 1 commit into from
Jul 13, 2016
Merged

Conversation

alexeagle
Copy link
Contributor

@alexeagle
Copy link
Contributor Author

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.

@alexeagle
Copy link
Contributor Author

cc @evmar

@mhegazy
Copy link
Contributor

mhegazy commented Jul 13, 2016

thanks!

@mhegazy mhegazy merged commit 049610e into microsoft:master Jul 13, 2016
@mhegazy
Copy link
Contributor

mhegazy commented Jul 13, 2016

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.

@weswigham
Copy link
Member

We actually have this function (or one very like it) in a few places inside our test harness, too. We should consolidate.

@evmar
Copy link
Contributor

evmar commented Jul 13, 2016

I was saying to Alex that we'd also like to be able to get the pretty
colors/formatting produced by tsc.

On Wed, Jul 13, 2016 at 12:32 PM, Wesley Wigham notifications@github.com
wrote:

We actually have this function (or one very like it) in a few places
inside our test harness, too. We should consolidate.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#9689 (comment),
or mute the thread
https://github.com/notifications/unsubscribe/AAAPBwJnjb3wuuisw4v80r9C5JMaTlD6ks5qVT1ggaJpZM4JLs6U
.

}

const category = DiagnosticCategory[diagnostic.category].toLowerCase();
output += `${ category } TS${ diagnostic.code }: ${ flattenDiagnosticMessageText(diagnostic.messageText, sys.newLine) }${ sys.newLine }`;
Copy link
Contributor

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()

Copy link
Contributor Author

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?

Copy link
Member

@weswigham weswigham Jul 13, 2016

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.

@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants