Well, the problem is rather, that JavaScript is a pretty bad language (nobody claimed otherwise, when it was designed in 10 days), so that using something like TypeScript makes it much better. Unfortunately your browser understands JavaScript, not TypeScript.
That's the immense tragedy of web development: It's a giant pile of excrement, because it's built on several things that were never meant to be what they are used for today.
It's also why I left a long time ago, and never looked back.
I left over a decade ago and went back to low level kernel programming.
In my opinion, everything else since is an attempt to find a way out of that mess.
I was there when the web happened, though only watching from the side lines. I also remember that there were more fitting approaches early on, but a lot of them suffered under the Internet's explosive growth: Some of the "sane" stuff at least would have needed concerted efforts for plans that have to be executed over time. But the web was already a thing, and people desperately wanted to do certain things with it. The quick hacks for that were available immediately, and they were cool: "Hah, look what I can do. You can now get a travel itinerary through your city's public transport system from the World Wide Web. Isn't that amazing?" (At the time, it was.)
I'm not saying you cannot have joy in web development. As you say, it just wasn't for me. For the reasons above.
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.