v2Swift preview for Apple Silicon macOS

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.

Runs onAndroid · ARTJVMmacOSPreviewiOSPlannedWebPlanned

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.tsn

JavaScript & TypeScript

Installed npm packages, compiled with ECMAScript semantics.

node_modules
check + lowerlower

TSN IR

Typed, checked and platform-neutral. The semantics are fixed here, once.

one shared spec
Java backendAndroid · ARTJVM
Java sourcejavacD8 / R8DEX
Swift backendmacOSPreviewiOSPlanned
Swift sourceswiftcLLVMmachine code
JavaScript backendPlannedWeb
JavaScriptbundler
Add a backend

Every IR operation sits in one exhaustive union, so a new backend learns at compile time what it still has to handle.

Backend roadmap

02Performance

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

TypeScript NativeJava backend
1.00× Kotlin
0.668 ns
Direct KotlinHandwritten baseline
0.667 ns
Rhino AOT, explicitHand-written bindings
59.19 ns
Hermes HBC + NitroStandalone engine
93.65 ns
Rhino AOT, reflectiveReflective Java interop
141.52 ns

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 results

140×

faster than Hermes with Nitro on a scalar host call, 0.668 against 93.65 ns

0.66ns

per numeric loop iteration with no host calls, against 0.79 ns in direct Kotlin

1.02×

the time of direct Kotlin for a synchronous update of a real Android View

03The 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
TypeScriptJVMSwift preview
bytebyteUnsupported
intintInt32
longlongUnsupported
floatfloatUnsupported
numberdoubleDouble
charcharUnsupported
booleanbooleanUnsupported

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.

MathPromiseasync / awaitMapSetArrayBufferErrorArrayStringDataViewUint8Arrayclassesclosuresfor…ofdestructuring

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.

$ tsn checkscale.tsn:1:23: error TSN2001: A type annotation is required.1 │ export function scale(x) {

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.

counter.tsnTypeScript
counter.tsnMainActivity.ktCounterView.swift
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
}
Android · Kotlin
button.setOnClickListener {
  state = CounterTs.next(state)
  label.text = CounterTs.describe(state)
}
iOS · SwiftUI concept
Button("Increment") {
  state = CounterTs.next(state)
}
Text(CounterTs.describe(state))

05Get 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.

01

Add the build plugin

Unpack the compiler as typescript-native next to the Example package. Attach the plugin to the Generated target.

Package.swift (excerpt)
platforms: [.macOS("15.0")],
dependencies: [
  .package(path: "../typescript-native/swiftpm")
],
// In the Generated target
plugins: [
  .plugin(name: "TypeScriptNativePlugin",
          package: "swiftpm")
]
02

Call TypeScript from Swift

Add main.tsn alongside a handwritten Swift source in Sources/Generated. Import Generated in the Consumer executable.

TypeScript and Swift (excerpts)
// 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)
03

Build and run

Run the installed launcher from Example. Then follow the SwiftPM guide to locate and run Consumer.

Terminal
../typescript-native/bin/tsn swift build \
  --package-path . \
  --configuration debug \
  --triple arm64-apple-macosx15.0 \
  -Xswiftc -swift-version -Xswiftc 6

Ship TypeScript
as native code.

Open source under the MIT License. Try the Android starter, the macOS Swift preview or the browser playground.