News for hackers. Stuff that matters.
Re:How JavaScript engines achieve great performance by Spivak on Wednesday November 24, 2021 @05:26PM (#29335897)
This seems like such an odd complaint because TS is very loudly purposely unsound. So much of TS is purposely unsound. Like unless you turn on an option disabling it function parameters are contravariant! If you write a function that takes a Dog you can pass an Animal and it will type check!
Re:How JavaScript engines achieve great performance by ragnese on Wednesday November 24, 2021 @09:39PM (#29337691)
It can be as loud and purposely unsound as it wants. That won't stop me from thinking it's a bad tool.

The problem is that function parameter variance is still wrong, even with all the strict flags. You just have to wrap the Dog/Animal in an Array or object. Pass in an { pet: Dog } to a function that accepts a { pet: Animal }, and the function can replace your Dog with a Cat, and TypeScript is perfectly happy to let you call `o.pet.bark()` afterwards.

Re:How JavaScript engines achieve great performance by Spivak on Wednesday November 24, 2021 @11:59PM (#29338349)
Like I get you but I genuinely can not thing of a single time I’ve ever hit this problem organically. I can’t even think of a time I’ve ever even though to modify a parameter when writing JS. I think if the language made every type immutable when passed to a function I wouldn’t even notice.

It’s not an excuse because where possible I think TS should be stricter but I don’t think stuff like this really gets in the way of it providing me value when writing code.