TypeScript in Go: Microsoft's New Native Port Project Explained
Are you curious about Microsoft's innovative project that brings TypeScript to the Go programming language? This article dives deep into the microsoft/typescript-go
project, exploring its goals, current status, and how you can get involved. Discover the power of a native TypeScript port.
What is typescript-go
?
Microsoft's typescript-go
is a staging repository for the development of a native port of TypeScript. This exciting endeavor aims to bring the benefits of TypeScript's type safety and modern JavaScript features to the Go ecosystem. This could improve tooling and developer experience for Go projects that interact with JavaScript or require TypeScript compilation capabilities. One of the goals may be to reduce the reliance on Node.js for TypeScript-related tasks.
Key Benefits of a Native TypeScript Port in Go
What advantages does this native port offer?
- Performance: A Go-based TypeScript compiler could potentially offer performance improvements compared to the standard JavaScript-based compiler, especially in environments where Go is already the primary language.
- Integration: Tighter integration with Go toolchains and build systems could simplify development workflows.
- New Possibilities: Could unlock new possibilities for using TypeScript in server-side and other Go-centric environments.
Current Status: What's Working and What's Not?
The project is currently under active development, with various features in different stages of completion. Here's a breakdown of the current status:
-
Done:
- Program creation
- Parsing/scanning
- Type resolution
- Type checking
-
In Progress:
- Emit (JS output)
- Watch mode (prototype)
-
Not Ready:
- JavaScript-specific inference and JS Doc
- JSX
- Declaration emit
- Build mode / project references
- Incremental build
- Language service (LSP) - Prototype only
- API
Remember that this is a work in progress and bugs may exist.
Getting Started with typescript-go
: Build and Run Locally
Want to experiment with typescript-go
? Here’s how to get started:
- Prerequisites: You'll need Go 1.24 or higher, Node.js with npm, and
hereby
. - Clone the Repository: Use the following command, ensuring you clone with submodules:
- Initialize Submodules (if needed): If you've already cloned, run:
- Install Dependencies:
- Run Tasks via
hereby
:
Running tsgo
(TypeScript in Go)
After building, you can run built/local/tsgo
. This behaves similarly to tsc
and respects tsconfig.json
. For a higher fidelity experience with regular tsc
, use tsgo tsc [flags]
.
Try the LSP Prototype
You can also test the Language Service Protocol (LSP) prototype:
- Run VS Code in the repo workspace (
code .
). - Copy
.vscode/launch.template.json
to.vscode/launch.json
. - Press
F5
(or useDebug: Start Debugging
from the command palette).
This launches a new VS Code instance using Corsa LS as the backend. Verify that "typescript-go" is an option in the Output pane.
Contributing to the Project
Contributions and suggestions are welcome! Make sure to agree to the Contributor License Agreement (CLA).
Long-Term Vision
The long-term plan is to merge the contents of this repository into microsoft/TypeScript
. As a result, this repo and its issue tracker will eventually be closed; treat discussions and issues accordingly.
Key Takeaways About TypeScript in Go
typescript-go
is a Microsoft project exploring a native Go port of the TypeScript compiler.- The project is under active development, with various features in different stages of completion.
- Interested developers can clone and run locally to try out the current state of the project.
- Contributions and suggestions are welcome, following the project's contribution guidelines.
- The project aims to enhance performance, integration, and unlock new possibilities for using TypeScript in Go environments.
Who are the Contributors?
Here's a shoutout to some of the contributors behind this project!