For the record, I think Javascript is fine (with some nasty warts), and Typescript is a great addition. The idea that TS is great but JS sucks is silly.
Exactly, it makes it "more palpable".
> The idea that TS is great but JS sucks is silly.
Just to be clear, I absolutely did not say that. Instead, I'd rather agree with your statement that TS only makes things better. But there is only so much it can do in that ecosystem, even if a good type system does notably improve things.
Everything that's below that is still what it was.
Typo: Palatable, obviously, not palpable. Too late to edit.
There's no accounting for taste, but... aren't we still taking about polished turds on top of a pile of excrement? "Palatable" is not the word I expected to see in this subthread.
Isn't all programming just layers of abstraction that make the layers underneath it more usable?
If you view Typescript as a standalone language that is another abstraction -- just like every other programming language -- that may make it more palatable. Yes, it's technically a superset of JavaScript, but I don't think anyone uses it that way. It would defeat the purpose, like buying a car and then tearing out the seats, air conditioner, and sound system.
Actually... typescript's type system could work quite well in other languages and is in fact in some fashion being ported over to multiple, Python's great turnaround on type hints a few years ago was obviously inspired by it.
So, I disagree. The type system makes a wart of a language into something passable, which is a great achievement.
I know it all gets compiled away in JS and all, but Pydantic is surprisingly ergonomic to use and type hints are sort of a suggestion, albeit available at runtime.
Closest I've seen is Zod, but the syntax looks horrendous IMO. Maybe you look past it eventually though.
I have made such a library myself: https://github.com/decoverto/decoverto
Another library would be https://github.com/typestack/class-transformer
The casting doesn't guarantee the JSON from your server fits the interface, but it WILL ensure any downstream use is correct, and also enable auto complete for its fields (assuming your IDE supports it).
I've been using JavaScript on and off for nearly 20 years, and TypeScript is a massive improvement.