TypeScript in Go? Microsoft's Innovative Port and What It Means for Developers
Microsoft is actively developing a native port of TypeScript to Go. This project, named typescript-go, aims to bring the power of TypeScript's type checking and tooling to the Go ecosystem. Let's explore what this means for developers.
What is TypeScript-Go?
Typescript-go represents an interesting bridge between two popular languages. It's a staging repository for the development of a native TypeScript port, leveraging Go. This project has garnered a significant amount of attention with over 13.8k stars on GitHub, showcasing the community's interest in this endeavor.
Key Benefits of TypeScript-Go
- Familiar Syntax: Write TypeScript code and leverage your existing knowledge.
- Performance: Potentially faster execution due to Go's compiled nature.
- Integration: Seamlessly integrate TypeScript logic into Go-based applications.
- Early Access: Developers can experiment and contribute to the project's development.
How to Get Started with TypeScript-Go
Interested in trying the TypeScript native port? Here's how to get started:
-
Clone the Repository: Use the command
git clone --recurse-submodules https://github.com/microsoft/typescript-go.git
to ensure you get all necessary submodules.- If you've already cloned, run
git submodule update --init --recursive
.
- If you've already cloned, run
-
Install Dependencies: Make sure you have Go 1.24+ and Node.js with npm installed.
-
Run Build Tasks: Use
hereby build
,hereby test
,hereby lint
, andhereby generate
for building, testing, and code generation. -
Run
tsgo
: Trybuilt/local/tsgo
after building; it respectstsconfig
and prints performance stats. Use the commandtsgo tsc [flags]
for higher fidelity execution compared to regulartsc
.
Current Status and What's Working
While still a work in progress, typescript-go has made significant strides; here’s the current breakdown:
- Done: Program creation, parsing/scanning, type resolution and checking.
- In Progress: JavaScript-specific inference, JS Doc, Emit (JS output), Watch mode.
- Not Ready: JSX, Declaration emit, Build/project references, Incremental build, Language service (LSP), API.
This native port is actively evolving. Keep an eye on the project's progress for upcoming features like JSX and declaration emit.
Running the LSP Prototype: A Step-by-Step Guide
Want to test the Language Service Protocol (LSP) prototype? Here’s how:
- Open the repository workspace in VS Code (
code .
). - Copy
.vscode/launch.template.json
to.vscode/launch.json
. - Press
F5
(or useDebug: Start Debugging
).
This will launch a new VS Code instance with the Corsa LS backend. Confirm "typescript-go" is in the Output pane.
Contributing to TypeScript-Go
The project welcomes contributions. Be sure to follow the Microsoft Open Source Code of Conduct and the Contributor License Agreement (CLA).
The Future of TypeScript and Go
Microsoft anticipates merging this repository into the main TypeScript repository. Ultimately, the typescript-go project is poised to bring significant changes to both the TypeScript and Go communities.