113
submitted 10 months ago by [email protected] to c/[email protected]

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
[-] [email protected] 60 points 10 months ago

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.

[-] [email protected] 21 points 10 months ago

I haven’t need any

need any

any

How even dare you. PR denied.

[-] [email protected] 3 points 10 months ago

I would say sorry, English isn't my first language but that would be a lie 😬

[-] [email protected] 13 points 10 months ago* (last edited 10 months ago)

Same, but I come from a C++ background so strong typing is in my blood. This sounds like people who write bad code complaining because the language/transpiler won’t let them write bad code.

[-] [email protected] 2 points 10 months ago

That doesn't seem a fair assessment at all. In strongly typed languages the types are part of the base syntax and usually not onerous, but rather straightforward to write. In TypeScript they're tacked on in a way that makes quite a lot of work for developers while also making the code difficult to read and reason about (although good syntax highlighting certainly helps.)

[-] [email protected] 7 points 10 months ago

I don't do java- or typescript but that guy's comment definitely translates as "I want to keep on writing messy code and you can't force me to learn to clean my shit up".

[-] [email protected] 3 points 10 months ago

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.

[-] [email protected] 3 points 10 months 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).

[-] [email protected] 1 points 10 months ago

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

this post was submitted on 10 Sep 2023
113 points (98.3% liked)

Out of the loop

10399 readers
1 users here now

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

founded 1 year ago
MODERATORS