this post was submitted on 10 Sep 2023
105 points (99.1% liked)

Out of the loop

13275 readers
1 users here now

A community that helps people stay up to date with things going on.

founded 2 years ago
MODERATORS
 

I keep seeing posts of some drama with typescript. What happened?

you are viewing a single comment's thread
view the rest of the comments
[–] De_Narm@lemmy.world 69 points 2 years ago (15 children)

Some rather big projects started to remove TS, which upset the community. One if not the biggest is Turbo, from the Ruby-on-Rails guy. He said: "[TS] pollutes the code with type gymnastics that add ever so little joy to my development experience, and quite frequently considerable grief. Things that should be easy become hard". Now there is a bit of a battle whether or not TS is actually all that great.

[–] yyyesss@lemmy.world 57 points 2 years ago (8 children)

In my experience, that means they're doing it wrong.

I find that Typescript adds a lot of joy to my development experience. And I haven't need any "gymnastics" since I invested in learning Typescript.

[–] Cratermaker@discuss.tchncs.de 3 points 2 years ago (2 children)

I've heard it's more of a problem on the library side. But I've personally had pains with ts when working with quirky features such as enums or discriminating unions. Part of the problem in my opinion is that the types all disappear at runtime, so you lose a lot of the joy of a statically typed language. For example, an API can pass you unexpected garbage and all your ts type wrangling helps not at all.

[–] FooBarrington@lemmy.world 3 points 2 years ago

Well yes, if you don't take care of properly typing external data, you won't have it properly recognised. But that's the same in any language that e.g. consumes external JSON data. Use the tools that Typescript gives you (like type guards) or the tools the community has built (like io-ts).

[–] jpeps@lemmy.world 1 points 2 years ago

For your API issue, have you tried using type guards or something more sophisticated like Zod?

load more comments (5 replies)
load more comments (11 replies)