# TScert only accepts TypeScript functions it can prove safe in Lean

Original title: TScert: A Sound Core for TypeScript

> Hacker News story 50366465 · language: en · submitted 2026-11-04
> Web version: https://zeli.app/story/50366465
> About this feed: https://zeli.app/llms.txt · Agent guide: https://zeli.app/skill.md

▲ 25 · by [bpierre](<https://news.ycombinator.com/user?id=bpierre>) · 💬 10
[original](<https://github.com/cristianoc/TScert>) · [HN discussion](<https://news.ycombinator.com/item?id=50366465>)

## Summary

TypeScript's checker is deliberately unsound: any, type assertions, unchecked index reads, and covariant arrays let code that passes tsc still read undefined where a type promises string. TScert is an independent checker whose soundness is proved in Lean. It never trusts inferred types; an untrusted producer proposes claims, an untrusted search proposes a certificate, and the proved checker validates it. At v0.94 it verifies 643 of 686 functions in its own tools/ front end, refusing any and type assertions outright.

## Key quote

> For every input that meets its annotations, the function's translation into a formal model never applies an operation to a value it does not fit, and never returns a value outside its result type.

## HN discussion (10 comments)

### [gavinray](<https://news.ycombinator.com/item?id=50380821>)

> \> Acceptance proves, of the function's translation into the calculus, that for inputs and a heap meeting their declared types it does not get stuck and does not return a value outside its result type.
>
> TypeScript's type-checker already proves the latter bit, no?

### [SSchick](<https://news.ycombinator.com/item?id=50380870>)

> I'd like examples/cases this catches  that aren't handled by the existing compiler.

### [conartist6](<https://news.ycombinator.com/item?id=50378933>)

> There's there is this little, really piddlingly small problem that TS isn't a sound language. Its type system, for convenience, pretends JS works in ways that are not how JS ACTUALLY works
>
> You can of course slap a formal solver in without knowing that, which is evidently what this person did

---

## Cite

- Page: https://zeli.app/story/50366465
- Date: 2026-11-04
- Source: github.com (https://github.com/cristianoc/TScert)
- Hacker News: https://news.ycombinator.com/item?id=50366465

## Other languages

- zh: https://zeli.app/zh/story/50366465 · markdown: https://zeli.app/zh/story/50366465.md
- ja: https://zeli.app/ja/story/50366465 · markdown: https://zeli.app/ja/story/50366465.md
- ko: https://zeli.app/ko/story/50366465 · markdown: https://zeli.app/ko/story/50366465.md
- de: https://zeli.app/de/story/50366465 · markdown: https://zeli.app/de/story/50366465.md
- es: https://zeli.app/es/story/50366465 · markdown: https://zeli.app/es/story/50366465.md
- ru: https://zeli.app/ru/story/50366465 · markdown: https://zeli.app/ru/story/50366465.md
