-
Notifications
You must be signed in to change notification settings - Fork 585
Add support for extendedDiagnostics json
output
#835
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
base: main
Are you sure you want to change the base?
Add support for extendedDiagnostics json
output
#835
Conversation
cmd/tsgo/main.go
Outdated
@@ -295,7 +298,44 @@ func runMain() int { | |||
} | |||
stats.add("Total time", totalTime) | |||
|
|||
stats.print() | |||
if opts.devel.extendedDiagnostics != "" { |
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.
This isn't really the same thing as the original tsc flag; I would not personally want to add this flag, at least not under this name.
Why not just parse out the current output, which is what needs to be done with old tsc as well?
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.
Why not just parse out the current output, which is what needs to be done with old tsc as well?
For exactly that reason, the code we wrote on our side to parse it feels pretty goofy and brittle. Happy to think of other names! The context for me is that we send this information to Datadog, so it's pretty nice to not have to maintain that code that parses out of stdout because we have to scan through potentially thousands of lines of errors to find what were looking for. When we were working on reducing our tsc memory usage, we were even keeping track of these metrics for builds with failures.
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.
Needing to send this information somewhere is making me more nervous than before. If we add devel
flags here, they're temporary until we can discuss and agree on a real flag that will also be present in tsc. tsgo itself is going to go away and be replaced tsc (with extra flags), so I would be wary about adding a flag that we'll just remove later...
json
output
Context: We've been working on trying to lower our memory usage for TSC by tracking it in places like Datadog. The current way we do this is a little awkward because we to have to parse it from both successful and failing output like so:
with awkward code to handle being able to stream out the output and write it to a file so a separate file can process it.
It feels pretty jank and I figure maybe this could be a place to step forward with json output. Open to input, as I know I'm hijacking the existing
--extendedDiagonstics
flag, and it seems like Typescript Go seems to be intentionally emitting the diagnostics unconditionally.Example usage:
tsgo -p tsconfig.json --extendedDiagnostics=test.json
writes totest.json
tsgo -p tsconfig.json --extendedDiagnostics=tmp/test.json
writes totmp/test.json
tsgo -p tsconfig.json --extendedDiagnostics=inline
writes it to stdout as texttsgo -p tsconfig.json
omitting the flag makestsgo
silent (unless there are errors)I feel like this might be particularly useful as large repos migrate to Typescript Go and want to have an understanding of how much better execution time and memory allocations are. Spoiler: they are great!