TypeScript,
compiled native.
Write TypeScript with real native types. One compiler lowers it to TSN IR, then emits Java for Android and the JVM or Swift for the Apple Silicon macOS preview. No JavaScript engine, no bridge, no reflection.
export class Counter {
private count: int = 0
increment(step: int): int {
this.count += step
return this.count
}
}public class Counter {
int count = 0;
public Counter() {}
public int increment(int step) {
this.count += step;
return this.count;
}
}public final class Counter {
var count: Int32 = 0
public init() {}
public func increment(_ step: Int32) -> Int32 {
count &+= step
return count
}
}01How it works
One IR,
every platform.
Write TypeScript Native, the typed dialect, and import JavaScript and TypeScript packages from npm. The compiler lowers both to TSN IR, a typed intermediate representation that pins down the semantics. Each backend emits idiomatic source for its platform, and the platform toolchain takes it from there.
TypeScript Native
The typed dialect, with int, float and the other native types.
counter.tsnJavaScript & TypeScript
Installed npm packages, compiled with ECMAScript semantics.
node_modulesTSN IR
Typed, checked and platform-neutral. The semantics are fixed here, once.
one shared specEvery IR operation sits in one exhaustive union, so a new backend learns at compile time what it still has to handle.
Backend roadmap02Performance
As fast as
handwritten Kotlin.
We hold every backend to the code you would write by hand. On Android the Java backend lands within noise of direct Kotlin on a scalar host call, and two orders of magnitude ahead of an embedded JavaScript engine.
Scalar host call
Nanoseconds per iteration · lower is better
Java backend on Android. Median of five fresh processes, 40 warmups and 20 measured invocations each, API 36 ARM64 emulator on an Apple M5 Max, November 9, 2026, original single-file compiler. Swift results against handwritten Swift follow.
Methodology and raw results140×
faster than Hermes with Nitro on a scalar host call, 0.668 against 93.65 ns0.66ns
per numeric loop iteration with no host calls, against 0.79 ns in direct Kotlin1.02×
the time of direct Kotlin for a synchronous update of a real Android View03The language
TypeScript with
native types.
The JVM backend compiles a subset of ECMAScript 2026 with fixed-width primitives and native imports. The Swift preview supports explicitly typed scalar functions and selected native calls and callbacks. Swift checks reject classes with TSN1010.
Real primitive types
On the JVM, choose an exact width for fields, parameters and results. In Swift preview signatures, int maps to Int32 and number maps to Double.
byteshortintlongfloatdoublecharboolean| TypeScript | JVM | Swift preview |
|---|---|---|
| byte | byte | Unsupported |
| int | int | Int32 |
| long | long | Unsupported |
| float | float | Unsupported |
| number | double | Double |
| char | char | Unsupported |
| boolean | boolean | Unsupported |
Call native code
Import Android classes from their Java package. The Swift preview can call supported functions from Swift modules.
// Android
import { TextView } from "android.widget"
import { Bundle } from "android.os"
// Swift preview
import { NSRange, NSIntersectionRange }
from "Foundation"ECMAScript on the JVM
The JVM backend supports features such as Map, Promise and typed buffers within the documented subset.
Idiomatic native APIs
Call generated Java methods from Kotlin or Java. Call exported scalar functions through the generated Swift namespace.
// spacing.tsn
export function doubleSpacing(
points: int,
): int { return points + points }
// Kotlin
val gap = SpacingTs.doubleSpacing(6)
// Swift
let gap = SpacingTs.doubleSpacing(6)Errors at build time
Anything outside the language fails the build with a located diagnostic, never at runtime.
04Everywhere
Write it once.
Ship it native everywhere.
Share TypeScript logic with a Kotlin UI on Android. The SwiftUI counter shows a future iOS example.
export interface CounterState {
readonly count: int
readonly step: int
}
export function next(state: CounterState): CounterState {
return { count: state.count + state.step, step: state.step }
}
export function describe(state: CounterState): string {
return "Count: " + state.count
}button.setOnClickListener {
state = CounterTs.next(state)
label.text = CounterTs.describe(state)
}Button("Increment") {
state = CounterTs.next(state)
}
Text(CounterTs.describe(state))TypeScript Counter
Count: 3
IncrementCounter
Count: 3
Increment05Get started
Build the
Swift preview.
Build on Apple Silicon with macOS 26.6 or later and Xcode 27.2 (Swift 6.4.2). The app targets macOS 15.0 (arm64-apple-macosx15.0). Use the macOS compiler archive and follow the SwiftPM setup guide to build and run the example. For Java output, see the Android starter or the desktop JVM guide.
Add the build plugin
Unpack the compiler as typescript-native next to the Example package. Attach the plugin to the Generated target.
platforms: [.macOS("15.0")],
dependencies: [
.package(path: "../typescript-native/swiftpm")
],
// In the Generated target
plugins: [
.plugin(name: "TypeScriptNativePlugin",
package: "swiftpm")
]Call TypeScript from Swift
Add main.tsn alongside a handwritten Swift source in Sources/Generated. Import Generated in the Consumer executable.
// Sources/Generated/main.tsn
import { nativeTwice } from "NativeHelpers"
export function twice(value: int): int {
return nativeTwice(value)
}
// Sources/Consumer/main.swift
import Generated
precondition(MainTs.twice(3) == 6)Build and run
Run the installed launcher from Example. Then follow the SwiftPM guide to locate and run Consumer.
../typescript-native/bin/tsn swift build \
--package-path . \
--configuration debug \
--triple arm64-apple-macosx15.0 \
-Xswiftc -swift-version -Xswiftc 6Ship TypeScript
as native code.
Open source under the MIT License. Try the Android starter, the macOS Swift preview or the browser playground.