News for hackers. Stuff that matters.
Re:TypeScript 4.1 by Analemma_ on Thursday November 19, 2020 @07:38PM (#25156162)
It's an unfortunate situation, because so long as people are writing popular frameworks/libraries that horribly abuse the dynamic nature of JavaScript, the TypeScript team sort of has no choice but to try and wrestle the language into supporting it. But I agree that this is getting out of hand. I still like TypeScript but with each new release it's getting harder to claim with a straight face that it's "easier" than vanilla JS when you have to grok this increasingly convoluted type system.
Re:TypeScript 4.1 by munificent on Thursday November 19, 2020 @07:49PM (#25156227)
> horribly abuse the dynamic nature of JavaScript

It's not a horrible abuse if you aren't trying to make the framework/library statically typed in the first place.

Idiomatic APIs for dynamically typed languages use the flexibility of dynamic types. Idiomatic APIs for statically typed languages use the structure of static types.

The problem comes when you try to put one into the other's world. It's like watching a fish flop around on land. There's nothing intrinsically wrong with fish locomotion, it's just not optimized for that environment.

Re:TypeScript 4.1 by ImprobableTruth on Friday November 20, 2020 @05:54AM (#25159233)
>It's not a horrible abuse if you aren't trying to make the framework/library statically typed in the first place.

Of course it is, because even if there's no type system the people using the library still have to make sense of the complexity. A function with a dozen, context-sensitive overloads that accepts data without a clear pattern isn't just hard to type, it's also hard to understand for a user. Even with dynamic typing you should be able to clearly state what a function does.

Re:TypeScript 4.1 by bobbylarrybobby on Thursday November 19, 2020 @08:31PM (#25156483)
Presumably, to work with the original JavaScript, you still had to understand the convoluted type system that you created, or else be ok with not being able to reason about your code. At least with typescript you have the computer helping you reason about it.
Re:TypeScript 4.1 by badlucklottery on Thursday November 19, 2020 @09:31PM (#25156812)
Yup. It's an attempt to formalize the mess that already exists in many JS libraries.

That's why, even if I don't plan on using Typescript itself for a project, I prefer libraries that have type declarations or are natively Typescript. It shows the library authors at least attempted to understand the type system they were creating.

Re:TypeScript 4.1 by tengbretson on Thursday November 19, 2020 @11:08PM (#25157220)
My favorite part about typescript becoming ubiquitous is that it is making people into more disciplined JavaScript programmers. The amount of cutesy overloading that was common in the early node days seems to be slowly waning.
Re:TypeScript 4.1 by mssundaram on Friday November 20, 2020 @02:19AM (#25158043)
> cutesy overloading

Haha, great way to put it