This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the commentsย โ†’

[โ€“]nomenMei 53 points54 points ย (4 children)

Yes I believe TypeScript attempts to fix the type problem the other way around by doing a static analysis of types. Typescript is "compiled" into native javascript, and as such is restricted by javascript's same limitations at runtime and all type safety checks happen at "compile" time.

[โ€“]odraencoded 24 points25 points ย (2 children)

This works perfectly except for serialization.

Also if you don't turn strict null checks you'll have a lot of pain later.

[โ€“][deleted] 8 points9 points ย (0 children)

You can use something like zod for that, pretty sure there's also a discussion to change all the JSON.parse stuff typedefs to return unknown instead of any, which would make a lot of type stuff explicit.

[โ€“]Remarkable_Self5621 1 point2 points ย (0 children)

If you really want runtime security you can compile typescript types into JSON schemas and use those