Skip to content

About

A native ahead-of-time (AOT) and JIT compiler for TypeScript, built on LLVM/MLIR. It compiles .ts files directly to native executables, WebAssembly, or runs them on the fly via a built-in JIT — no Node.js or JavaScript runtime required.

Topics

Resources

Code of conduct

Stars

779 stars

Watchers

13 watching

Forks

Latest commit

 

History

710 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TypeScript Native Compiler

Powered by LLVM|MLIR

Developed by Claude Code

Donate Test Build (Windows) Test Build (Linux)

A native ahead-of-time (AOT) and JIT compiler for TypeScript, built on LLVM/MLIR. It compiles .ts files directly to native executables, shared libraries and WebAssembly, or runs them on the fly via a built-in JIT — no Node.js or JavaScript runtime required.

Targets: Windows, Linux, Android (arm64-v8a, armeabi-v7a, x86_64), WebAssembly (wasm32, wasm64).

Contents

Quick start

Download tslang from Releases, or try it on Compiler Explorer.

File hello.ts:

function main() {
    print("Hello World!");
}

Run it with the JIT:

tslang hello.ts

Or compile it to an executable (on Linux add --relocation-model=pic):

tslang --emit=exe hello.ts
hello.exe
Hello World!

Start a new project:

tslang --new Test1

creates a Visual Studio Code project, and

tslang --cmake Test1

a CMake project for mixed C++/TypeScript (see What's new for building it).

More in Running and compiling programs: a larger example, the JIT cache, debugging JIT code with GDB, and the environment variables the linker uses.

Memory models

How heap memory is managed is selected with -mm=:

flag
-mm=gc garbage collection (Boehm) the default
-mm=rc reference counting - freed as soon as the last reference goes, no collector, no libgc does not collect reference cycles
-mm=none nothing is ever freed short-lived programs
-mm=own single ownership inferred at compile time, like Rust's borrow checker - no collector, no counting in development; ownership that cannot be proven is a compile error

See memory-models.md and the -mm=own guide. Under -mm=own tslang runs within 1.1-1.4x of idiomatic Rust on an object-heavy ray tracer and on par with it on array loops — see Performance.

Documentation

Topic Page
Running with the JIT, compiling executables, debugging JIT code docs/running.md
Android: cross-compiling and building the runtime libraries docs/android.md
WebAssembly docs/wasm.md
Memory models (gc, rc, none) docs/memory-models.md
The -mm=own single-owner model docs/own-memory-model.md
Benchmarks against Rust and C++ docs/performance.md
C and C++ bindings with tsbindgen docs/tsbindgen.md
Calling C++ classes (@cpp) docs/cpp-classes.md
Building the compiler from source docs/building.md
What's new and roadmap docs/whats-new.md
JavaScript built-in objects library Default Library repo
How-to guides and more Wiki

Showcase: native_ts_graphics

native_ts_graphics is a set of 25 real-time 3D graphics samples — TypeScript ports of NVIDIA's Donut samples on Direct3D 12 and Vulkan, from basic_triangle to ray tracing, meshlets and work graphs — compiled to native code with tslang. .ts files are a first-class CMake language (TSLANG) linked with the C++ framework through a C interop layer, and the samples run on Windows and Android.

Community

License

This project is licensed under the MIT License — see the LICENSE file for details.

Contributing

Issues and pull requests are welcome. See the Wiki for documentation, build notes, and how-to guides.

About

A native ahead-of-time (AOT) and JIT compiler for TypeScript, built on LLVM/MLIR. It compiles .ts files directly to native executables, WebAssembly, or runs them on the fly via a built-in JIT — no Node.js or JavaScript runtime required.

Topics

Resources

Code of conduct

Stars

779 stars

Watchers

13 watching

Forks

Releases

Sponsor this project

Packages

Used by

Contributors

Languages