Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
T

TypeScriptCompiler

> 编程语言
Open source

TypeScript Compiler (by LLVM)

757 stars0 likes0 views
WebsiteGitHub

About

TypeScript Compiler (by LLVM)

TypeScript Native Compiler

Powered by

Developed by 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.

CI Status

Contents

  • What's new
  • Roadmap
  • Demo
  • Try it online
  • Example
  • Running your code
    • As JIT
    • Debugging JIT code with GDB (Linux)
    • As a native executable
    • As WebAssembly
  • Memory models
  • Building from source
  • Community
  • License

What's new

  • Implemented try/catch exception handling in the JIT on Windows (x64 SEH unwinding via a custom LLJIT runtime)

  • Migrared to LLVM 22.1.8

  • Migrated to Visual Studio 2026 (Windows build chain)

  • JavaScript Built-in objects library [Default Library repo]

  • Visual Studio Code project

bat
tslang --new Test1
  • CMake project (mixed C++/TypeScript, TSLANG registered as a first-class CMake language)
bat
tslang --cmake Test1

Generates a ready-to-build project (CMakeLists.txt, CMakePresets.json, main.cpp, sample .ts sources and the cmake/ TSLANG language modules). Build it with:

bat
cd Test1
cmake --preset default && cmake --build --preset default
  • Strict null checks
typescript
let sn: string | null = null; // Ok
let s: string = null; // error
  • Improved Template Literal Types
typescript
type Color = "red" | "green" | "blue";
type HexColor = `#${string}`;
  • Public, private, and protected modifiers
typescript
class Point {
    private x: number;
    #y: number;
}

const p = new Point();
p.x // access error
p.#y // error
  • Class from Tuple
typescript
class Point {
    x: number;
    y: number;
}

class Line {
    constructor(public start: Point, public end: Point) { }
}

const l = new Line({ x: 0, y: 1 }, { x: 1.0, y: 2.0 });
  • Compile-time ifs
typescript
function isArray(value: T): value is T {
    return true;
}

function gen(t: T)
{
    if (isArray(t))
    {
        return t.length.toString();
    }

    return "int";
}

const v1 = gen(23); // result: int
const v2 = gen([]); // result: 0
  • Migrated to LLVM 19.1.3

  • Improved generating debug information — more info here: Wiki:How-To

bat
tslang --di --opt_level=0 --emit=exe example.ts
  • More What's New entries on the wiki

Roadmap

  • Migrating to LLVM 22.1.8
  • Shared libraries
  • JavaScript Built-in classes library

Demo

See the release page for a recorded demo

Try it

Open the WASM example on Compiler Explorer

Chat Room

Want to chat with other members of the TypeScriptCompiler community?

  • GitHub Discussions (preferred)
  • (legacy)

Example

…

Run

bat
tslang --emit=jit --opt --shared-libs=TypeScriptRuntime.dll example.ts

Result

Department name: Accounting and Auditing
The Accounting Department meets each Monday at 10am.

Run as JIT

File hello.ts

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

Build

bat
tslang hello.ts

Result

Hello World!

Debugging JIT code with GDB (Linux)

JIT-compiled TypeScript can be debugged at source level with GDB — breakpoints on .ts lines, stepping, and backtraces all work. The JIT registers every compiled object with the debugger via the standard GDB JIT interface, so an attached GDB picks up the DWARF debug info at runtime.

Two things are required:

  • pass --di so the compiler emits debug information;
  • run without --opt (JIT debug registration is only enabled when optimizations are off).
bash
gdb --args tslang --di hello.ts
(gdb) break hello.ts:2
Make breakpoint pending on future shared library load? (y or [n]) y
(gdb) run

The breakpoint stays pending until the JIT compiles and registers your code, then binds and stops with full source context:

Thread 1 "tslang" hit Breakpoint 1, main () at hello.ts:2
2           print("Hello World!");

From there the usual GDB commands work on the JIT'd frames: next, step, info locals, bt.

Notes:

  • The (No debugging symbols found in tslang) warning at startup refers to the compiler binary itself and is harmless — the debug info for your code arrives when the JIT registers it.
  • The debugger; TypeScript statement is also supported: it compiles to a debug trap instruction, so execution stops exactly there when a debugger is attached. Without a debugger attached it terminates the process with SIGTRAP, so remove it when you are done.
  • For LLDB, enable its JIT loader first: settings set plugin.jit-loader.gdb enable.

Compile as Binary Executable

Make sure you have download tslang from releases first.

The compile process may use a few environment variables so the linker can find the runtime libraries, then invoke tslang with --emit=exe. Edit the paths to match your checkout — the C:\dev\... / ~/dev/... values are only examples.

Variable Points to
GC_LIB_PATH Boehm GC library (the garbage collector)
LLVM_LIB_PATH LLVM/MLIR libraries
TSLANG_LIB_PATH TSLANG runtime library
DEFAULT_LIB_PATH Default library

Compile on Windows

Build

bat
tslang --emit=exe hello.ts

Run

hello.exe

Result

Hello World!

Compile on Linux (Ubuntu 20.04 and 22.04)

Build

bash
./tslang --emit=exe hello.ts --relocation-model=pic

Run

./hello

Result

Hello World!

Compiling as WASM

WASM build on Windows

Build

bat
tslang.exe --emit=exe -mm=none -mtriple=wasm32-unknown-unknown hello.ts

Run run.html

Click to expand the full run.html WebAssembly loader

xml

    

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=gc is the default and needs no thought. -mm=rc reclaims memory deterministically and holds close to the working set - a ray tracer that reaches 114 MB under -mm=none holds 4.1 MB, against garbage collection's 5.8 - but objects that refer to each other in a cycle are never freed under it, which is the same trade Swift makes with ARC.

See docs/memory-models.md for which shapes leak, which do not, and what to do about it.

Build

Build on Windows

Windows Requirements

  • Visual Studio 2026
  • ~50 GB of free disk space (LLVM/MLIR build dominates this)

The hardcoded C:\dev\... paths in the scripts below are examples — adjust them to your checkout location.

First, precompile dependencies

bat
cd TypeScriptCompiler
prepare_3rdParty.bat

To build TSLANG binaries:

bat
cd TypeScriptCompiler\tslang
config_tslang_release.bat
build_tslang_release.bat

Build on Linux (Ubuntu 20.04 and 22.04)

Linux Requirements

  • gcc or clang
  • cmake
  • ninja-build
  • ~50 GB of free disk space (LLVM/MLIR build dominates this)
  • sudo apt-get install libtinfo-dev

First, precompile dependencies

bash
chmod +x *.sh
cd ~/TypeScriptCompiler
./prepare_3rdParty.sh

To build TSLANG binaries:

bash
cd ~/TypeScriptCompiler/tslang
chmod +x *.sh
./config_tslang_release.sh
./build_tslang_release.sh

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.

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

C++

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言