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

Include results from --extendedDiagnostics when using the compiler API #61229

Open
6 tasks done
MariaSolOs opened this issue Feb 20, 2025 · 4 comments
Open
6 tasks done

Comments

@MariaSolOs
Copy link
Contributor

πŸ” Search Terms

extendedDiagnostics, compiler API

βœ… Viability Checklist

⭐ Suggestion

For users of the TypeScript compiler API, it would be extremely useful to include the performance statistics obtained when using the --extendedDiagnostics compiler option.

From the review I've done in this codebase, it seems like this performance information is only reported when invoking tsc directly.

πŸ“ƒ Motivating Example

"The compiler API can now report performance information when enabling the extendedDiagnostics compiler option"

πŸ’» Use Cases

  1. What do you want to use this for? Investigating performance variations in a project that interacts with TypeScript using the compiler API.
@jakebailey
Copy link
Member

The main gotcha is that the perf data is global (via the native performance built-in), not scoped, so doesn't lend itself to use via the APIs at all.

@MariaSolOs
Copy link
Contributor Author

The main gotcha is that the perf data is global (via the native performance built-in), not scoped, so doesn't lend itself to use via the APIs at all.

@jakebailey could you please elaborate on this?

A workaround I was thinking of was constructing my own report using the program from const program = createIncrementalProgram() and then get the stats I need like executeCommandLine.ts does here, but are you saying that this wouldn't work because there's global state that I wouldn't have access to?

@jakebailey
Copy link
Member

See:

This all is global state, backed by globalThis.performance. All of the data for extendedDiagnostics (and even --trace) is global. Having this be in the public API would be a challenge because this performance marking / tracing was never meant to be enabled outside of tsc.js, where we are only ever doing one compilation. In fact, the code that produced the extendedDiagnostics output wasn't even present in typescript.js until #58057 when I moved it there.

@jakebailey
Copy link
Member

That being said, if you read the code in the second link, there is information from Program that you could use, that isn't global, and that could be done today. There are projects out there (like attest) which do this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants