null-safe · sum types · zero runtime
JavaScript, Perfected.
A sound, null-safe superset of JavaScript — sum types, exhaustive match, no any. Compiles to plain JS with zero runtime overhead.
npm i -g superjsFeatures
Everything TypeScript should have been
Built from first principles. Every decision exists to make your code more correct.
Null Safety
T? is the only nullable type. No null exceptions at runtime.
const x: string? = null
const y: string = x ?? "default"Sum Types
Algebraic data types with exhaustive match — no impossible states.
type Result<T,E> = Ok(T) | Err(E)
const r: Result<number,string> = Ok(42)Match Expressions
Exhaustive pattern matching. The compiler forces you to handle every case.
match r {
Ok(v) => v * 2,
Err(e) => 0
}No any
any is banned. Use dynamic when you need an escape hatch — it's explicit.
// ❌ const x: any = fetch()
// ✅ const x: dynamic = fetch()Gradual Typing
Mix typed and untyped code freely. Migrate at your own pace.
function greet(name) { // untyped
return "Hello, " + name
}Zero Runtime
Compiles to plain JS. No runtime library, no overhead, ships anywhere.
// sjs compile app.sjs --out app.js
// → plain JavaScript, no importsComparison
The same problem, solved correctly
Switch tabs — same program, three outcomes.
// Super.js
function divide(a: number, b: number): Result<number, string> {
if (b === 0) return Err("division by zero")
return Ok(a / b)
}
match divide(10, 0) {
Ok(v) => console.log(v),
Err(e) => console.error(e)
}Try it live
Edit the Super.js code on the left, hit Run, see compiled JavaScript on the right.
Press Run to compile
Quickstart
From zero to type-safe in 60 seconds
Install the compiler
npm install -g superjsWrite your first program
// hello.sjs
type Greeting = Formal(string) | Casual(string)
function greet(g: Greeting): string {
return match g {
Formal(name) => "Good day, " + name + ".",
Casual(name) => "Hey " + name + "!"
}
}
console.log(greet(Formal("World"))) // Good day, World.
console.log(greet(Casual("friend"))) // Hey friend!Compile and run
sjs compile hello.sjs --out hello.js
node hello.jsEcosystem
Works everywhere JavaScript does
Get Started
Start writing Super.js today.
Type-safe by default. Zero configuration. Compiles to plain JavaScript.
npm i -g superjs