CLI Reference

Usage

ts-aot <input.ts> [options]

The input file can be .ts, .tsx, .js, or .jsx.

Options

Output

FlagDescription
-o <file>Output executable path. Required.

Optimization

FlagDescription
-O0No optimization (default). Fastest compilation.
-O1Basic optimizations.
-O2Standard optimizations. Good balance of speed and compile time.
-O3Maximum optimization. Best runtime performance.

Debug

FlagDescription
-gGenerate debug symbols (.pdb on Windows).
--dump-irPrint generated LLVM IR to stdout.
--dump-hirPrint HIR (intermediate representation) to stdout.
--dump-typesPrint inferred types to stdout.

Advanced

FlagDescription
--bundle-icuEmbed ICU data in executable (~29MB larger, no external icudt74l.dat needed).
--gc-statepointsEnable precise GC roots via LLVM statepoints (experimental).
--legacy-parserUse Node.js-based parser instead of native C++ parser.

Examples

# Basic compilation
ts-aot app.ts -o app.exe

# Optimized build
ts-aot app.ts -o app.exe -O2

# Debug build with symbols
ts-aot app.ts -o app.exe -g

# Inspect generated IR
ts-aot app.ts --dump-ir -o /dev/null

# Check type inference
ts-aot app.ts --dump-types -o /dev/null

# Self-contained executable (no external ICU data file)
ts-aot app.ts -o app.exe --bundle-icu

Entry Point

All programs must define a user_main() function:

function user_main(): number {
    // Your program here
    return 0;  // Exit code
}

The compiler generates a main() function that initializes the runtime (GC, libuv event loop, ICU) and calls user_main().

Supported File Types

ExtensionHandling
.tsTypeScript with full type analysis
.tsxTypeScript + JSX
.jsJavaScript (dynamic/slow path)
.jsxJavaScript + JSX

TypeScript files get optimized codegen paths (typed arrays, integer specialization, flat objects). JavaScript files still compile but fall back to boxed any values for untyped operations.