TLA-ts
Formally verifies TypeScript code by transpiling it to TLA+ and model checking every state to report violations with their traces.
At a Glance
About TLA-ts
TLA-ts is an open-source research project by Aiden Bai that formally verifies TypeScript code with TLA+. Running npx tla [file].ts transpiles the file into a TLA+ module, checks every reachable state, and reports any violations along with the steps that caused them. It is released under the MIT license.
What It Is
TLA-ts is a formal verification tool for TypeScript and JavaScript. Under the hood it is a transpiler from TypeScript/JavaScript to TLA+, paired with a TypeScript reimplementation of the TLC model checker and the TLAPM proof manager. The project states this reimplementation runs about 2× faster than TLC on its published benchmarks. It accepts a TypeScript file, a TLA+ spec, or a TLA+ module with proofs.
How Verification Works
Top-level let declarations become state variables. A variable with a value starts at that value, and one without a value starts at every value of its type. Exported functions are interpreted by their shape:
- A function that changes state is an action, called from every state with every value of its parameter types.
- A function with no parameters that returns a boolean is an invariant, and the check fails in any state where it returns false.
- A function that returns any other value is a check, and the check fails where it throws.
JSDoc tags such as @always, @eventually, @alwaysEventually, @eventuallyAlways, @leadsTo, @fair, @strongFair and @constraint express temporal properties, fairness and search constraints. Numbers, strings and arrays are checked over small finite domains. For example, numbers range from -3 to 3 and arrays are up to 3 elements long.
CLI and Programmatic API
The CLI can transpile and check a TypeScript file, check a TLA+ spec (reading a .cfg file from the same folder), or prove a module with npx tla tlapm Module.tla. A separate TypeScript model can be named [name].tla.ts. The programmatic API exposes compile, check, prove, parseModule, parseConfig and formatValue, plus typed errors. compile runs in Node only, while the project also provides a browser playground.
Using It with Coding Agents
The site offers a prompt for coding agents that points them to its llms.txt and asks them to verify the project's TypeScript, show each violation with its causing steps, and ask before changing code. The site's case studies list bugs it found in projects such as Effect, SolidJS, Ink and TypeScript, with fix pull requests in the author's forks.
Collections
Popular collections
- Give Your Agent Design Taste
Collection by @linetwk
- Run YOLO Mode Without Risking Your Laptop
Collection by @reproalex
- ADE List - December 2026
Collection by @mateorivera17
- UI Design Skills for Coding Agents
Collection by @mayachen
Add TLA-ts to one of your collections.
Community Discussions
Be the first to start a conversation about TLA-ts
Share your experience with TLA-ts, ask questions, or help others learn from your insights.
Pricing
Open Source
TLA-ts core CLI and library, licensed under the MIT License; free to use, copy, modify and distribute.
- MIT License
- Run via npx tla [file].ts or npm install tla
- Transpiles TypeScript/JavaScript to TLA+
- Reimplementation of TLC/TLAPM in TypeScript
- Programmatic API: compile, check, prove
Capabilities
Key Features
- Transpiles TypeScript/JavaScript into TLA+
- Model checks every reachable state and reports violations with step traces
- Invariants, actions and checks inferred from exported functions
- Temporal property tags (@always, @eventually, @leadsTo, @fair and more)
- TLAPM-style proof checking of TLA+ modules
- Checks existing TLA+ specs with TLC configuration files
- Programmatic API: compile, check, prove, parseModule, parseConfig, formatValue
- Multi-worker checking
- Browser playground
- Coding agent prompt via llms.txt
