Skip to content

Implement tsgo functionality in tsc, promote tsc to main entrypoint #857

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 13 commits into from
May 12, 2025

Conversation

jakebailey
Copy link
Member

@jakebailey jakebailey commented May 11, 2025

This moves tsgo tsc to the top, implementing the features that are missing from tsc but present in the old tsgo entrypoint (so, adding --quiet, --singleThreaded, --pprofDir, --showConfig, --diagnostics). LSP and API subcommands are now flags, e.g. tsgo --lsp .... I also removed --printTypes, which I don't think is needed now that we have full testing.

tsgo now no longer prints out stats, so --diagnostics is needed to show that once again.

The only thing that is a downgrade is --version, which now goes back to the hardcoded version number, undoing #834. I'm not entirely certain how to handle this since we technically don't want to include this info by default in the command. Maybe we need --extendedVersion or something. But, the commit info can also be extracted by go version -m path/to/tsgo on the mod line:

./built/local/tsgo: go1.24.3
	path	github.com/microsoft/typescript-go/cmd/tsgo
	mod	github.com/microsoft/typescript-go	v0.0.0-20250511072254-f0dab1c56b80	
	dep	github.com/dlclark/regexp2	v1.11.5	h1:Q/sSnsKerHeCkc/jSTNq1oCm7KiVgUMZRDUoRu0JQZQ=
	dep	github.com/go-json-experiment/json	v0.0.0-20250223041408-d3c622f1b874	h1:F8d1AJ6M9UQCavhwmO6ZsrYLfG8zVFWfEfMS2MXPkSY=
	build	-buildmode=exe
	build	-compiler=gc
	build	-tags=noembed
	build	CGO_ENABLED=1
	build	CGO_CFLAGS=
	build	CGO_CPPFLAGS=
	build	CGO_CXXFLAGS=
	build	CGO_LDFLAGS=
	build	GOARCH=amd64
	build	GOOS=linux
	build	GOAMD64=v1
	build	vcs=git
	build	vcs.revision=f0dab1c56b80da8dfb86b4981797c188b44dfa7f
	build	vcs.time=2025-05-11T07:22:54Z
	build	vcs.modified=false

jakebailey added 13 commits May 10, 2025 20:19

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
@Copilot Copilot AI review requested due to automatic review settings May 11, 2025 17:17
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR promotes the tsc entrypoint by integrating missing flags previously available on the tsgo entrypoint. Key changes include adding new compiler options (‑‑quiet, ‑‑singleThreaded, ‑‑pprofDir), reworking diagnostic reporting and configuration display, and refactoring multi‑threading support by replacing bool with tristate for single‑threaded mode.

Reviewed Changes

Copilot reviewed 29 out of 29 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
internal/tsoptions/parsinghelpers.go Added new cases to parse compiler options for pprofDir, singleThreaded, and quiet.
internal/tsoptions/declscompiler.go Introduced new command-line option declarations for quiet, singleThreaded, and pprofDir.
internal/execute/tsc.go Updated diagnostic reporting, integrated pprof profiling, reworked showConfig handling, and refactored compileAndEmit to report timing stats.
internal/execute/outputs.go Modified createDiagnosticReporter to use the full compiler options and introduced new functions for formatting output statistics.
internal/diagnostics/generate.go Updated diagnostic generation to include extra messages from a new extraDiagnosticMessages.json file.
internal/core/compileroptions.go Added new compiler option fields (pprofDir, singleThreaded, quiet).
internal/compiler/program.go Refactored singleThreaded support by changing the field type from bool to core.Tristate and using a helper method for resolution.
cmd/tsgo/* Removed deprecated flags and legacy functions; updated the main entrypoint argument parsing to delegate command execution to the new execute package.
_packages/api/src/client.ts & _extension/src/extension.ts Updated flag values from “api”/“lsp” to “--api”/“--lsp”.
README.md Updated documentation to reflect the new behavior of the tsgo entrypoint.

@@ -35,6 +39,12 @@ func executeCommandLineWorker(sys System, cb cbType, commandLine *tsoptions.Pars
return ExitStatusDiagnosticsPresent_OutputsSkipped, nil
}

if pprofDir := commandLine.CompilerOptions().PprofDir; pprofDir != "" {
// !!! stderr?
Copy link
Preview

Copilot AI May 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The inline comment "!!! stderr?" appears to be a temporary note. Consider clarifying or removing it once the profiling output destination is finalized.

Suggested change
// !!! stderr?
// Begin profiling and write output to the specified directory

Copilot uses AI. Check for mistakes.

@@ -96,6 +95,7 @@ func NewProgram(options ProgramOptions) *Program {

p.configFileName = options.ConfigFileName
if p.configFileName != "" {
// !!! delete this code, require options
Copy link
Preview

Copilot AI May 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The comment suggesting deletion of legacy code indicates an incomplete cleanup. Once the new options handling is verified, remove this commented‐out block to reduce clutter.

Copilot uses AI. Check for mistakes.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixing this is a little annoying but I plan to send a separate PR for that.

@jakebailey jakebailey added this pull request to the merge queue May 12, 2025
Merged via the queue into main with commit bc3195e May 12, 2025
23 checks passed
@jakebailey jakebailey deleted the jabaile/cli-switchover branch May 12, 2025 20:43
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

Successfully merging this pull request may close these issues.

None yet

3 participants