Skip navigation
introducing TScert, a sound core for TypeScript.
0:00 / 0:44

introducing TScert, a sound core for TypeScript.

Cristiano Calcagno

@ccrisccris1.5K followers

Visit on X
511 likesDownloadOriginal post

39,357 views

introducing TScert, a sound core for TypeScript. - TypeScript functions accepted only with a proof - a checker whose soundness is proved in Lean - first target: its own front end, 628 of 684 functions verified a research project, unfinished by design. read it, inspect it 👇

18 Comments

Comments from the original post on X (Twitter)

  • lauren's profile picture

    @poteto

    👀

    21 likes

  • Cristiano Calcagno's profile picture

    @ccrisccris

    the story: the code:

    15 likes

  • Cristiano Calcagno's profile picture

    @ccrisccris

    TScert stands on decades of work on types and semantics: Appel & McAllester, Ahmed, Wright & Felleisen, Reynolds, Abadi & Cardelli, Frisch, Castagna & Benzaken, Pierce, Milner et al., JSCert, ECMA-262 and Lean 4. Each entry says what TScert takes from it:

    15 likes

  • Michael K's profile picture

    @MKassabov

    Is there an example that isn't fixed by just having a stricter ts config?

    5 likes

  • Cristiano Calcagno's profile picture

    @ccrisccris

    Yes. The README example is one a flag does catch (noUncheckedIndexedAccess); nearly all the strict flags were considered during development. No flag catches this: const xs: string[] = []; const ys: (string | number)[] = xs; ys.push(1); for (const x of xs) x.toUpperCase(); // TypeError Same for method parameter bivariance, or a callback that mutates the array being mapped.

    4 likes

  • Sora Morimoto's profile picture

    @smorimoto

    Long time no see, Cristiano. As for me, I've recently written a TypeScript extractor plugin for Rocq. It now handles pretty much everything, but the problem is that the generated code is about twice as slow as hand-optimized code. I don't think it'll be an issue for things like state machines, but sorting algorithms are a real struggle.

    2 likes

  • Ethan Alley's profile picture

    @EthanAlley

    probably dumb question, but i seem to remember typescripts type system being unsound even in theory, not just as implemented. are you changing the type systems semantics to get around that or do i misremember?

    2 likes

  • Cristiano Calcagno's profile picture

    @ccrisccris

    TypeScript has many strictness configurations. None of them is strict enough to be sound (for a variety of reasons). But it is compatible with such a setting. Then the question becomes being expressive enough to support the pattern that people (now agents) write.

    1 like

  • Ethan Alley's profile picture

    @EthanAlley

    right so it is stricter than the strictest typescript (and therefore semantically unlike any existing typescript config someone runs)?

    1 like

  • Cristiano Calcagno's profile picture

    @ccrisccris

    Yes: because it uses a verified semantic model it can only be stricter than any unsound configuration. The question then is pragmatic expressivity rather than soundness.

    1 like

  • @'s profile picture

    @notegone

    just curious why you chose NON-AI MIT License for a project programmed and documented with Claude

    1 like

  • Filip Falcon's profile picture

    @filipfalcon

    howdy fellow Lean TypeScripter 🤝 coming at it from the other side on @egonitida: the theory and proofs live in Lean, types and tests are generated from it, and Effect runs the implementation. you verify, i derive, keen on your take on it

  • Kala's profile picture

    @kalapowered

    the other 56 functions have suddenly remembered an urgent appointment

  • Tyler Kendrick's profile picture

    @TylerKe11504158

    I love this. Well done.

  • ron's profile picture

    @Aron_Adler

    > functions accepted only with a proof say more about this? what does a proof look like?

  • Daniel Montilla's profile picture

    @DanieIMontilla

    typa shi mfs do to not use effect

  • Dominik's profile picture

    @EternitiesAI

    628 of 684 verified, so the interesting bugs are hiding in the last 56 functions

  • Injamul Islam's profile picture

    @Iam_Injamul

    @grok what is this? Looks like a typescript replacement?