top | item 32572237

(no title)

734129837261 | 3 years ago

TypeScript has come a long way, but one of its biggest issues is the complete lack of FORCED sensible naming conventions.

Generics are the worst offender, with people often using a single letter to represent something that's both hard to keep track of and impossible to intuitively make sense of.

Any type should be: `TUser` and not `User`.

Any generic should be: `<GPerson>` and not `<P>`.

Any interface should simply not exist because it's TypeScript, not InterfaceScript. The addition of classes into JavaScript was unnecessary sugar and they should just do away with it. So, `type` for everything, no more `interface`.

But that's a whole different subject.

I've also noticed that people over-engineer TypeScript. I had a team mate telling me he wanted to make URLs type-safe. I asked: "But why?" and he had no answer. There was no problem preceding it. There wasn't anyone asking for it. It wouldn't solve something we didn't know. It would just make the codebase more confusing to deal with because, in his solution, there wasn't a single place where routes were defined. Nope, routes would be inferred from Pages and their use of Page props.

It was genius. But it also was over 2000 (two THOUSAND) lines of code that I didn't feel like I wanted to deal with.

I gave him permission to publish it and get the open-source community involved. Once it's tried & tested over the course of many users and lots of time, we could consider it.

He wasn't happy. He was also not very pragmatic. TypeScript seems to do that to people. The "never any `any`"-crowd is so tiresome.

discuss

order

erulabs|3 years ago

> It was genius. But it also was [...] code that I didn't feel like I wanted to deal with

You sound like a sysadmin my friend! This is exactly how I feel about plenty of software that I've allowed into production, but that now keeps me up at night and distracts me from spending time with my kids.

One of the most useful things about plain JavaScript at this point is seeing if it causes genuine disgust. It's a razor for idealism versus pragmatism.

schwartzworld|3 years ago

> The addition of classes into JavaScript was unnecessary sugar and they should just do away with it.

Weird. Classes are one of my favorite features, even before using TS. I do a lot of data modeling using functional techniques and the class keyword allows a really intuitive way of encapsulating things.