logoalt Hacker News

conartist6 • today at 1:39 PM • 2 replies • view on HN

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


Replies

austin-cheney • today at 2:33 PM

Yes and no. TypeScript's type system is duck typing, but if you type absolutely everything it does closely describe actual JavaScript behavior. You can even set rules in your tsconfig file to forbid implicit null or undefined, but I don't do that in my own code.

conartist6 • today at 1:51 PM

If you're interested I am happy to offer what I know on the topic but it won't be good news for you.

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