Turbocharge Your TypeScript: Exploring Microsoft's Experimental Go Implementation
Want to experience TypeScript with a performance boost? Microsoft is actively developing typescript-go
, a Go-based implementation of the TypeScript compiler. This project aims to bring potential performance improvements to your TypeScript development workflow. Let's dive in and see what this exciting project offers!
What is TypeScript-Go and Why Should You Care?
Typescript-go
is an experimental project by Microsoft, exploring the possibility of reimplementing the TypeScript compiler in Go. This opens the door for potentially faster compilation times and improved resource utilization. While it's still early in development, it represents a significant step towards optimizing the TypeScript development experience.
Benefits of Checking Out TypeScript-Go:
- Explore Future Performance: Witness firsthand how Go can potentially enhance the speed of TypeScript compilation.
- Contribute to Innovation: Get involved in an experimental project pushing the boundaries of TypeScript development.
- Early Access to New Features: Experiment with features and improvements as they become available.
- Understand the Inner Workings: Gain deeper insights into the TypeScript compiler by seeing it implemented in a different language.
Getting Started with TypeScript-Go: A Developer's Quick Guide
Ready to give typescript-go
a spin? Here's how to get your hands dirty:
-
Prerequisites: Make sure you have Go (1.24+), Rust (1.85+), Node.js with npm, and
hereby
installed. -
Clone the Repository: Use the following command, making sure to include submodules:
Or, if you've already cloned, initialize the submodule:
-
Run Setup: Navigate to the project directory and run
npm ci
. -
Build and Test: Leverage
hereby
for common tasks (similar to the main TypeScript repo):hereby build
- Verify the project builds.hereby test
- Run all tests.hereby install-tools
- Install additional tools.hereby lint
- Run linters.hereby format
- Format the code.hereby generate
– Generate Go code (e.g. diagnostics, committed to repo).
Note: Even without
hereby
, standard Go tools likego build
andgo test
will work as expected.
Running the TypeScript-Go Compiler (tsgo)
After building successfully, the built/local/tsgo
executable becomes your new TypeScript compiler. It generally respects tsconfig.json
but also outputs performance statistics.
For more accurate tsc
behavior, use:
Trying Out the LSP Prototype
To experience a Language Server Protocol (LSP) prototype with typescript-go:
- Open the repository workspace in VS Code (
code .
). - Copy
.vscode/launch.template.json
to.vscode/launch.json
. - Start debugging (F5 or "Debug: Start Debugging" from the command palette).
A new VS Code instance will launch, utilizing "Corsa LS" as the backend. Verify the setup by checking for "typescript-go" in the Output pane.
Current Status and What Works
Keep in mind that typescript-go
is a work in progress. Expect bugs and incomplete features. Before reporting issues, consult the project's documentation to understand what's currently "done," "in progress," or still in the "prototype" phase. Understanding the current status of features like definitions, checking, and more can save you valuable time and help the developers focus on critical issues.
Contributing to the Project
Microsoft encourages contributions to typescript-go
. If you're interested in contributing code, suggestions, or bug reports, ensure that you have agreed to the Contributor License Agreement (CLA). Also, adhere to the Microsoft Open Source Code of Conduct.
The Future of TypeScript at Microsoft
The long-term vision is to merge the contents of the typescript-go
repository into the main microsoft/TypeScript
repository. Accordingly, the typescript-go
repository and its issue tracker will eventually be closed. Keep this eventual migration in mind when participating in discussions or logging issues.