The documentation, tests, breaking run attempts when developing, and flipping back and forth between different source files it replaces, almost painlessly, are 100% worth it.
And you can trivially "nope" out of it anywhere you want if it's getting in your way too much, and congrats, you're back to lovely, pain-free, JS. /s
I was a big fan of static types for many years (I also did Java and C++) so I understand your point of view perfectly but I also understand that it is incorrect. The fact that my POV seems so bizzare suggests that you haven't considered it thoroughly before.
> C++
What happens when you call main(argc, argv) with the incorrect argc parameter? There the exact same problem that TypeScript faces at the start of every single C/++ program.
Validate your payloads with JSON schema if you don't trust the server/backend. JSON schema is designed to type-check at runtime and is therefore the correct tool for the job.
Don't curse the hammer if it is unable to loosen bolts.
I have a few applications that use the same API, and it’s consumed using a shared library in Typescript. There’s a little bit of code that takes raw messages, parses and validates them, then returns typed objects. This means we can use those typed objects confidently throughout the rest of the codebase, making some useful guarantees about the content of them and detecting errors at compile time. Parsing code is isolated and tested in a small area, like you light use unsafe code in Rust.
Yes, it would be nice if this was easier, such that parsing was automatically handled based on those types (and I don’t doubt that there are projects out there that do this). But that obviously doesn’t mean that no value is added.
It’s totally fine if Typescript doesn’t suit your applications, or your way of working - but it might be useful to consider that other people aren’t idiots.
Please edit such swipes out of your comments here, regardless of how wrong or annoying you find someone else's comment. Your post would be much better without those bits and the swipe at the end.