everywhere I go
everywhere I go
- yeah our project uses typescript
- look inside
- any
everywhere I go
JavaScript is so ass, typescript is just putting ketchup on a rotten banana. Better just to choke it down quickly if you have to eat it, IMO.
I wouldn't say JavaScript is horrible, it's a fine little language to do general things in if you know JS well. I would say, though, that it is not a great language. Give me F# and I'm happy forever. I do not like typescript that much more than JS.
Back when I was still doing JS stuff, switching to TS was so good for the developer experience. Yeah, there's still JS jank, and types are not validated at runtime, which was a pain in the backend (pun intended), but still I much prefer it to vanilla JS
You know, you can validate data structures at runtime... and write unit tests... TS is not a substitute for those things.
as unknown as any
The people who use any
and non-strict TS are the same ones who complain about TS/JS letting them compare an object to an string array
if JS tried not only to use Lisp-like semantics but also Lisp-like syntax then probably we'd still be using it untyped
Any project that uses d3.
Why is that?
I don’t know why. Maybe the typings for it are just fucking bad. Or maybe d3 is very hard to use “correctly”, but still works most of the time even if invoked incorrectly (I doubt that). Or maybe d3 is so complex that the typings need to be complex, too, even if you don’t use the complexity (the type retured from selectAll has four type parameters, half of which are undefined
by default, the other half, null
).
In my defense, the backend contracts change so often in early development the any just made sense at first...
...and then the delivery date was moved up and we all just had to ship it...
...and then half of us got laid off so now there are no resources to go back and fix it...
...rinse, wash, repeat
Use the unknown type so at least someone might have enough brain cells to validate before casting because squiggles
Refactorings and changes are the prime reason to use TypeScript. You edit your data objects and get squigglies everywhere shit won’t work anymore. A godsend!
110% agree. But...
One job I worked at wouldn't let us do this because it created too large of a QA impact (lol). We were only allowed to modify code in the smallest section possible so that testing could be isolated and go faster.
At another job they mandated that TypeScript wasn't allowed because it "slowed down development". It was soooo laughable. The number of bugs introduced that could have been readily caught was absurd, but management never put the two pieces together.
I'd guess the lack of defined backend contracts is caused by the same issue that made you unable to fix those
any
later.Anyway, the frontend / backend split is stupid and ridiculous. It's even worse because both sides usually include tasks that do need to be split up.
Its sad how relatable this is
Record<string, unknown> ftw
Sadly, this is the way.