Hacker News new | ask | show | jobs
by pjmlp 1200 days ago
When I look at clever TypeScript, I always think the code was written by either Haskell or C++ template metaprogramming refugee, and this isn't good for the longevity of the language, see what happened to Scala's adoption because of it.
4 comments

Typescript will have no adoption problem. It is the defacto only compile to js language supported in NPM. It is also ergonomic to JS devs who want or are forced (at work) to use typing and an option on most scaffolding tools like NextJS or CRA. The fact that TS is actually very good just confounds this more!

It will live as long ad JS is popular. The main threat is web assembly which will make JS compatibility seem quaint.

Something should be pointed out to outsiders looking at typescript, otherwise they might get the wrong idea about the language.

In practice there seems to two different sides of typescript code.

1. Regular projects: tend to have rather easy to understand/write/maintain code.

2. Dependency code: tends to have code-golfed metaprogramming that the IDE uses to auto-magically autocomplete and highlight issues in regular project code.

While I'm an C++ refugee, most of the "clever" TS stuff I write is due to JS framework idioms creating duplicate work(redux-reducer typings...) or forcing 'any' escape doors to the degree TS use doesn't help. Doesn't mean I'm "above" using any escape hatches where appropriate though or keeping things "dumb" (most of my TS code is fairly monomorphic).
After coding it with it daily for the past year I can think of very few times I've had to write "clever" TypeScript. And half of those are now solved with TypeScript's new `satisfies` operator :P

The only consistently annoying thing about it is how dumb it plays with JavaScript's built in array methods but it still is sufficiently smart 80% of the time (and the other 15% a simple `as const` does the trick)

Yeah, this is why I wince every time TS gets another feature.

IMO it was entirely good enough for what it does quite a while ago. No need to add more—that's purely introducing risk (of the language's ecosystem getting worse, mainly) from my perspective.

On the contrary, many of the new TS features over the last year or more have been around making type inference smarter and allowing for less explicit typing
Yep! Or making type checking safer (this list is enormous), or better aligning TS specifics with how JS is actually used (upcoming 5.0 getting import specifiers more or less right as a great example).