Built on typescript-go
RunTypes does not reimplement TypeScript. It is built on typescript-go, the Go rewrite of the TypeScript compiler that ships as TypeScript 7 and runs as tsgo. It asks that compiler about your types, so you get the same answers TypeScript gives.
RunTypes as a Superset of TypeScript
RunTypes adds to TypeScript and never changes the language.
- Anything that works on typescript-go works with RunTypes. The same checker reads your types.
- 100% compatible. No compiler flag, no schema dialect. Point the plugin at your
tsconfig.jsonand your types are the schema. - A strict superset. You keep everything TypeScript gives you, plus runtime functions generated from the same types: validators, JSON round trip functions, mock data and reflection.
Extending typescript-go Without Modifying It
The RunTypes binary includes the complete compiler. It loads your tsconfig.json, builds the same program as tsgo and runs the same type checker. It turns your types into runtime code but does not report type errors.
$ npx mion --version # in parentheses: the typescript-go revision it was built with (varies by release)
mion 0.13.2 (tsgo 5a37e89)
tsgo (or tsc) to type check. For a project with no bundler, mion compile emits JavaScript and reports type errors like tsc.Current Limitations of the Compiler
RunTypes ships its own compiler. Each release is built with one typescript-go revision, not the TypeScript you install, so some bugs can come from that compiler itself.
For now, RunTypes runs as a second pass. The Go compiler has no hook for runtime libraries (microsoft/typescript-go#516), so tsgo and the RunTypes binary run as two separate processes. Each loads the project on its own, so your files are read twice.
The second read costs build time only and adds nothing to your bundle. If the compiler ever adds a supported plugin hook, RunTypes would run in a single pass.
See About mion RunTypes for the design, or the Quick Start to set it up.