TypeScript-Ultra-Strict
This is my proposal for TypeScript-Ultra-Strict: a stricter TypeScript for a world where AI writes most of the code.
Status: working MVP on the
mvpbranch.packages/cliimplementstsus checkandtsus build,packages/runtimeimplementsOption/Result/matchand the boundary layer, and all 26 projects underexamples/pass (npm install && npm run examples). The 5banned-*examples pass by being rejected with the right diagnostic codes.LEARNINGS.mddocuments what broke before the toolchain existed and how that shaped the design. The compiled output is plain ESM; the worker example (examples/23-cloudflare-worker) exports the Cloudflare{ fetch }module shape and runs against realRequest/Responseobjects, sowranglercan bundle it as-is.
TypeScript's early design decisions assumed humans would write and maintain it, so a lot of features exist to make a human's life easier. We valued speed over quality. With AI writing most of our code, we can flip that tradeoff and force the language to be declarative and verifiable, like Rust.
What changes
- Removes
nullandundefined. In their place,Option<T>andResult<T, E>become first-class types. This is the centerpiece: the removals below only work because these replacements exist. - Removes classes. Data is plain objects; behavior lives in functions.
- Removes
var. - Introduces an SDK for macros, used for pattern matching and variable destructuring over
Option,Result, and tagged unions. (TC39 already has a pattern-matching proposal in the pipeline; this accelerates where the language is heading.)
The interop boundary
Every existing DOM and npm API returns undefined, throws, and hands you classes. Ultra-Strict code never sees those directly. At the boundary, a checked bindings layer converts T | undefined and T | null into Option<T>, and throwing calls into Result<T, E>. Inside the boundary, the strict rules hold everywhere.
Why not just an eslint preset?
Banning classes, nulls, and var can be approximated with tsconfig and lint rules today. Two things need a real compiler:
- The macro SDK. This is the honest cost of the proposal: TypeScript's types are fully erasable, which is why esbuild and swc can strip them in a single fast pass. Macros break that property. The bet is that with AI writing the code, we should spend build-time budget on expressiveness and checkability rather than on keeping type-stripping trivial.
- The boundary layer, which needs type information to generate the
Option/Resultwrappers.
Why TypeScript?
Back in 2008, Google shipped Chrome and V8, and the industry built its edge compute on top of that runtime. Cloudflare Workers runs V8 isolates directly. Node, Deno, and Bun's ecosystem all trace back to it. JavaScript and ESM are the substrate that's already deployed everywhere.
TypeScript is the typed layer the ecosystem already adopted. Rather than asking everyone to move to a new language, Ultra-Strict is a subset-plus-macros of a language AI models already know deeply, targeting a runtime that's already everywhere.
Ideal UX
Any file with a .tsus extension (TypeScript Ultra Strict) is processed under the strict rules and compiled to plain JavaScript. .ts and .tsus files coexist in one project, so adoption is per-file: an AI agent can write new modules in .tsus while the legacy .ts code keeps working untouched. Importing a .tsus module from .ts just works; importing .ts (or any npm package) into .tsus goes through the boundary layer, which rewrites the types so nullable returns arrive as Option<T> and throwing functions arrive as Result<T, E>.
What a .tsus file looks like:
import { readFile } from "node:fs/promises"; // boundary-wrapped: returns Result
type User = { name: string; email: Option<string> };
const loadUser = async (path: string): Promise<Result<User, IoError>> => {
const raw = await readFile(path, "utf8");
return raw.map(parseUser);
};
// macro from the SDK
const greeting = match(user.email) {
Some(email) => `Reach me at ${email}`,
None => "No email on file",
};Tooling:
tsus buildcompiles to JS,tsus checktype-checks without emitting. Both run as an esbuild/swc plugin so existing bundler setups pick up.tsusfiles without config changes.- Editor support ships as a TypeScript language service plugin, so VS Code and every TS-aware editor get diagnostics, go-to-definition, and macro expansion previews for free.
- Diagnostics are machine-first: every error has a stable code, a JSON output mode, and a suggested fix, so an agent can consume
tsus check --jsonin a loop without parsing prose. Human-readable output is a rendering of the same data. - No new package manager and no new registry. npm packages work through the boundary layer, and published
.tsuspackages ship compiled JS plus.d.tsfiles, so consumers don't need to know the source language existed.