I’ve uncovered some heinous bugs hidden under `any` types that would have gone undetected in JavaScript alone, as well. “How did this ever work?” Good question to ponder as I fix the types AND the code….
If you’re content comes from a CMS, you’ll get hit with ‘cannot read property of undefined reading title’.
I honestly can’t go back to plain js if a client is responsible for the content.
But if the types are incorrect then it’s worse than plain js. Better put any and optional chain on everything.
I’ll bite. It’s the perfect balance between making things more tedious but providing huge productivity and reliability benefits of any typing system I’ve ever used.
Now stack traces work, no failed compilation because there is no build and it's faster than waiting on a build. Oh, and JS is backwards and forward compatible so less thrash.
It's so obviously the right balance of tradeoffs it's wild ppl choose otherwise. Zero rationale.
This! I feel a little more organized with how I package data now… which I appreciate cause I was winging it before that. Still new to TypeScript but I can see the benefits
I think that if you're a mega-brain then TypeScript can feel like it's in the way, but very difficult to create a middle layer from API to Frontend so that newbies can understand data structure. Until optional types get added to JavaScript, TS is sensible solution, much better than DocBlocks.
TS is superb for code in a regulated environment, where being a "mega-brain" is a negative. If you want auditable, reproducible code, that can be understood by someone who subs in for you during your 2 weeks of PTO, TS might be the best tool right now.
Typescript is genuinely difficult for library developers. It moves the responsibility of type juggling from the app developer's head to the library developer's code. App developers find it hard because they're writing more types than they should be
Comments
I honestly can’t go back to plain js if a client is responsible for the content.
But if the types are incorrect then it’s worse than plain js. Better put any and optional chain on everything.
Hinting of types via Intellisense? Awesome. Let's go.
Catching/preventing problems in the codebase? Good. That does help occasionally.
Jumping through hoops to get tsc to understand what you're trying to do in any mildly complicated piece of code: Burn it all to the ground.
It's so obviously the right balance of tradeoffs it's wild ppl choose otherwise. Zero rationale.
I recently built an entire fully-typed HTML parser from scratch using only JSDoc partially just to see if I could and... Turns out I could!
https://github.com/Gyanreyer/tempeh-parser
Ya, I’ve noticed that about it.
Seems everyone finds everything difficult and it's always the tech's fault.