v0.7.1 · MIT licensed · open source

Write TypeScript. Ship native binaries.

TypeNative compiles your TypeScript to Go and builds a single self-contained executable. No Node.js runtime, no node_modules, no bundler: one file you can copy anywhere and run.

npx typenative --new
Get started Star on GitHub

Early development: TypeNative compiles a growing subset of TypeScript, and every supported feature is backed by a runnable probe. See what compiles today.

todos.ts

import { readFileSync } from 'node:fs';

interface Todo {
  title: string;
  done: boolean;
}

const todos: Todo[] = JSON.parse(readFileSync('todos.json', 'utf8'));
const open = todos.filter((t) => !t.done);

console.log(`${open.length} of ${todos.length} still open:`);
for (const t of open) {
  console.log(`  - ${t.title}`);
}

code.go

// Code generated by TypeNative. DO NOT EDIT.
// (excerpt: //line directives removed, reformatted)

var todos *[]*Todo
var open *[]*Todo

func main() {
	todos = TnJSONParseTyped[*[]*Todo](
		TnReadFileString("todos.json", "utf8"),
		func(__jv_fzxc0WG0__ interface{}) *[]*Todo {
			return TnArrayRef[*Todo](__jv_fzxc0WG0__)
		})

	open = TnSlicePtr(func() []*Todo {
		__arrhof_NmNqfXqf__ := (*todos)
		__filterres_f71iezcB__ := make([]*Todo, 0, len(__arrhof_NmNqfXqf__))
		for _, __item_w4mFgqHS__ := range __arrhof_NmNqfXqf__ {
			if (func(t *Todo) bool { return !t.done })(__item_w4mFgqHS__) {
				__filterres_f71iezcB__ = append(__filterres_f71iezcB__, __item_w4mFgqHS__)
			}
		}
		return __filterres_f71iezcB__
	}())

	fmt.Println(TnNumStr(float64(len((*open)))) + " of " +
		TnNumStr(float64(len((*todos)))) + " still open:")

	for _, t := range (*open) {
		_ = t
		fmt.Println("  - " + t.title)
	}
}

type Todo struct {
	title  string
	done   bool
	__keys *[]string
}

terminal

$ npx typenative --source todos.ts --output todos --target linux/amd64 --release
Created native executable at: todos
$ du -h todos
2.6M	todos
$ ./todos
2 of 3 still open:
  - Ship v0.8
  - Cross-compile for arm64

Real input and output from TypeNative 0.7.1. The Go source is an excerpt: the runtime it calls is compiled into the same binary.

faster startup than Node.js
9.2×
hello-world: 4.9 ms vs 45.2 ms
less memory for a desktop app
6.7×
desktop-notes: 11 MiB vs 72 MiB
Node's HTTP throughput
1.6×
json-server: 94k vs 57k GET req/s
conformance probes
791
run in CI on Linux, macOS and Windows

Why TypeNative

The TypeScript you know, without the runtime

Write the TypeScript you already run under Node. TypeNative turns it into a native program that starts in milliseconds and ships as a single file.

  • Ship one file

    The output is a single self-contained executable: no Node.js install, no node_modules, no bundler. Copy it to a server and run it.

  • Start instantly

    No runtime to boot and no JIT to warm up. A hello world starts in about 5 ms instead of 45 ms, which you feel in every CLI invocation.

  • Run faster

    Compiled ahead of time to machine code through Go. Recursive fib(35) runs about 2× faster than Node, and hashing a directory tree about 3× faster.

  • Keep your TypeScript

    Same syntax, same types, and Node’s own APIs (node:fs, node:http, node:crypto…) with Node’s signatures. The examples run unchanged under both.

  • Reach into Go

    Import any Go package directly, as in import { Println } from 'go:fmt', when you need something Node doesn’t have.

  • Know what works

    Type errors and unsupported syntax are reported against your .ts lines before anything builds, and every feature has a runnable probe.

How it works

From .ts to a binary in one command

TypeNative drives the TypeScript compiler and the Go toolchain for you. Add --emit-go to keep the generated Go and read every step.

  1. .ts

    Type-check

    Your sources are checked by the TypeScript compiler against TypeNative’s type surface, with errors on your own lines.

  2. .go

    Transpile to Go

    Classes, generics, closures, async/await and generators are lowered to Go. Node and Web APIs come from TypeNative’s Go runtime.

  3. go build

    Compile

    The Go toolchain builds your code and the runtime to machine code. Everything is pure Go with no cgo, so it cross-compiles from any OS.

  4. binary

    Ship

    One executable for Linux, macOS or Windows, on amd64 or arm64. Nothing else to install on the target machine.

Cross-compile from any OS

No C toolchain and no target machine needed: pick an OS and CPU and build.

  • linux/amd64
  • linux/arm64
  • darwin/amd64
  • darwin/arm64
  • windows/amd64
  • windows/arm64
$ npx typenative --source main.ts --output bin/app --target linux/arm64 --release

Benchmarks

Measured, not promised

Every example runs unchanged under Node.js and as a TypeNative binary, and ships the bench.mjs harness that produced its numbers.

Times faster than Node.js Median per example · higher is better · Node.js = 1×
  1. yaml-cli 11.3× faster: per call · 9 ms vs 107 ms in Node
  2. todo-cli 10.2× faster: per command · 5.4 ms vs 54.8 ms in Node
  3. hello-world 9.2× faster: startup · 4.9 ms vs 45.2 ms in Node
  4. marked-cli 8.2× faster: per call · 13 ms vs 107 ms in Node
  5. angular-templates 4.3× faster: per template · 52 ms vs 223 ms in Node
  6. desktop-notes 3.9× faster: launch to first page · 24.8 ms vs 97.5 ms in Node
  7. react-compiler 3.5× faster: per file · 103 ms vs 364 ms in Node
  8. dupe-finder 2.8× faster: scan of 2,000 files · 231 ms vs 643 ms in Node
  9. fibonacci 2.1× faster: compute, fib(35) · 31.8 ms vs 66.1 ms in Node
  10. json-server 1.6× faster: GET requests per second · 94k vs 57k in Node
  11. mandelbrot-png 1.1× faster: render · 419 ms vs 462 ms in Node
  12. openai-chat 1.1× faster: per streamed answer · 700 ms vs 766 ms in Node
Show the numbers as a table
Example Measures Node.js TypeNative Result
yaml-cli per call 107 ms 9 ms 11.3×
todo-cli per command 54.8 ms 5.4 ms 10.2×
hello-world startup 45.2 ms 4.9 ms 9.2×
marked-cli per call 107 ms 13 ms 8.2×
angular-templates per template 223 ms 52 ms 4.3×
desktop-notes launch to first page 97.5 ms 24.8 ms 3.9×
react-compiler per file 364 ms 103 ms 3.5×
dupe-finder scan of 2,000 files 643 ms 231 ms 2.8×
fibonacci compute, fib(35) 66.1 ms 31.8 ms 2.1×
json-server GET requests per second 57k 94k 1.6×
mandelbrot-png render 462 ms 419 ms 1.1×
openai-chat per streamed answer 766 ms 700 ms 1.1×

Medians on Windows 11 Pro, AMD Ryzen 5 7600, Node.js v26.13.0, Go 1.27.4, TypeNative 0.7.0. json-server compares requests per second, so higher is better there too. Float-heavy (mandelbrot-png) and network-bound (openai-chat) work runs close to Node’s speed. Methodology and harnesses.

Showcase

Real packages, unmodified source

TypeNative resolves npm packages from node_modules and compiles them into your program. These four produce byte-for-byte the same output as Node on their own test suites.

  • yaml

    The yaml package’s own command-line tool, compiled from its unmodified npm source.

    yaml-test-suite cases identical to Node
    1,608 / 1,608
    faster per call
    11.3×
    examples/yaml-cli
  • marked

    The marked Markdown compiler and its CLI, compiled from unmodified source.

    spec cases identical to Node
    2,859 / 2,859
    faster per call
    8.2×
    examples/marked-cli
  • @angular/compiler

    Angular’s template compiler, 233 files, turning component templates into Ivy instructions.

    compliance-suite templates identical
    612 / 612
    faster per template
    4.3×
    examples/angular-templates
  • React Compiler

    babel-plugin-react-compiler with Babel and zod, about 470 files: the largest codebase TypeNative compiles.

    parity fixtures identical, errors included
    15 / 15
    faster per file
    3.5×
    examples/react-compiler
The black Mandelbrot set with glowing orange edges on a sky-blue gradient, rendered by the mandelbrot-png example
mandelbrot-png rendered this image and encoded the PNG by hand on node:zlib, with no image library. See the source.

It compiles itself

TypeNative’s own source builds into a native typenative binary that needs no Node.js and emits the same Go as the npm package.

How self-hosting works

Batteries included

The APIs you already use

Node’s modules keep Node’s signatures, Web APIs behave like the browser’s, and Go’s whole ecosystem is an import away.

Language

  • classes & decorators
  • generics
  • enums
  • async / await
  • generators
  • using
  • conditional & mapped types
  • bigint
  • symbols
  • destructuring & spread
  • JSX → HTML strings
  • dynamic import()

Web APIs

  • fetch
  • WebSocket
  • URL
  • URLPattern
  • Streams
  • Blob
  • FormData
  • TextEncoder
  • AbortController
  • EventTarget
  • MessageChannel
  • BroadcastChannel
  • structuredClone
  • crypto
  • performance
  • localStorage
  • Temporal
  • Intl
  • WebAssembly

Node.js modules node:*

  • assert
  • async_hooks
  • buffer
  • child_process
  • cluster
  • console
  • crypto
  • dgram
  • diagnostics_channel
  • dns
  • events
  • ffi
  • fs
  • http
  • http2
  • https
  • module
  • net
  • os
  • path
  • perf_hooks
  • process
  • punycode
  • querystring
  • readline
  • sea
  • sqlite
  • stream
  • string_decoder
  • test
  • timers
  • tls
  • tty
  • url
  • util
  • v8
  • wasi
  • worker_threads
  • zlib

Not available: node:vm, node:repl, node:inspector and node:trace_events, which need a JavaScript engine at run time, and the deprecated node:domain.

Call Go directly

Any Go package is one import away, with Go types mapped to TypeScript.

import { Println, Sprintf } from 'go:fmt';
import { ToUpper } from 'go:strings';
import * as runtime from 'go:runtime';

Println(Sprintf('Hello, %s!', ToUpper('gophers')));
Println('built for', runtime.GOOS + '/' + runtime.GOARCH);
Hello, GOPHERS!
built for windows/amd64

Desktop apps, one binary

Native windows on the OS webview, with menus, tray icons, notifications and IPC.

import { Application } from '@webviewjs/webview';

const app = new Application();
const win = app.createBrowserWindow({
  title: 'Notes',
  width: 800,
  height: 600,
});

win.createWebview({ html: '<h1>Hello from one binary</h1>' });
app.run();
$ npx typenative --source main.ts --output notes --gui --release

Get started

Your first binary in a minute

You need Node.js 26+ and Go 1.26+ on the machine that builds. The binaries you ship need neither.

  1. Scaffold a project

    Creates main.ts, package.json, tsconfig.json and a README.

    npx typenative --new
  2. Run it

    Transpiles, builds and runs main.ts in one step.

    npm run execute
  3. Ship a binary

    Builds one executable into bin/. Add --target to cross-compile for another OS or CPU.

    npm run build

Read the docs

FAQ

Questions, answered

Do the people running my binary need Node.js or Go?

No. The output is one self-contained executable. Node.js and Go are only needed on the machine that builds it.

Can it compile any TypeScript or npm package?

It compiles a subset of TypeScript and resolves npm packages from node_modules. Large packages such as yaml, marked, @angular/compiler and the React Compiler build from unmodified source, but TypeNative fits best for CLIs, servers and tools where you control the code. The conformance matrix lists exactly what works.

Is it always faster than Node.js?

No. The clearest wins are startup (about 9×) and memory (about a seventh of Node’s for a desktop app). Long-running hot loops over very dynamic code, such as any-typed values or class accessors, can be slower than V8’s JIT. The performance probes track which paths are faster and which are slower.

Can I see the Go it generates?

Yes. --emit-go <dir> writes the Go source, go.mod and vendored modules to a folder so you can read them or build them yourself with go build.

Is it ready for production?

TypeNative is in early development (v0.7.1). Every supported feature is backed by a runnable probe, and CI runs all of them on Linux, macOS and Windows. Check the conformance matrix for what your code needs before you rely on it.

What does it cost?

Nothing. TypeNative is open source under the MIT license.

Write TypeScript. Ship one file.

Free and open source under the MIT license.

npx typenative --new
Star on GitHub View on npm

Questions or ideas? Write to info@typenative.dev.