by preommr · 3y ago · 0 comments
If you're fighting typescript that much, then what's the point?
The point of using things like types is correctness that can be statically checked. Imagine writing java (or any static typed lang) code where you just pass around a base class( e.g. "Object") and explicitly cast up to what you want, there'd be no point in using that language.
Agreed - I find these "wrangling" situations to be uncommon, and roughly half of the time they happen because our code is bad and we need to change it. The other half - well, sure, it can be a pain in the ass, but there's no such thing as code so elegant that it never has some irritating high-effort corner cases. I'll take deterministic type wrangling over raw untyped JS.
Hence, the downside is doing a lot of work to describe things we already know whilst making code less readable (or at least longer).
I'm still largely in favor of Typescript, I'm just suggesting to not misrepresent the situation of not having Typescript.
(And ran.)