> 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? export function stale(xs: string[]): string {
const n = xs.length;
xs.pop();
return xs[n - 1];
}
You get undefined at runtime even though the signature says string. TScert won't take it unless you admit it in the return type, with string | undefined.You can of course slap a formal solver in without knowing that, which is evidently what this person did
Basically if you want your project to survive and thrive you're going to have to implement a new programming language that runs using the semantics that Typescript claims to have rather than the semantics it actually has because it's Javascript under the hood.
I mean, if you want to despair, just try to account for the potential behavior Javascript Proxies could introduce in your Lean proofs.
If you do it correctly, Lean should tell you that virtually every Javascript program that has ever been written is possibly wrong, mostly for reasons that have to do with the lies Typescript tells about Javascript