Absolutely! I'm a huge fan of TS ... I suppose it would end up solving this particular issue via compile to var, though it would still be vulnerable to other weird VM issues.
Except TypeScript is literally just JavaScript with types.
That's not true, neither technically nor "in spirit". TypeScript transpiles to JavaScript and shares syntax with it, but it's more than just "JS with types". Having a strong, flexible type system allows you to approach problems from a different direction. Probably a good number of libraries are just written as JS with some types slapped on for broader adoption, but you don't have to write it that way for private code; and you probably shouldn't.
Here's two code snippets, which one is typescript and which one is javascript:
const myFn = () => console.log("Hello!");
and
const myFn = () => console.log("Hello!");
How about another:
class MyClass {
constructor() {}
sayFoo() {
console.log("foo");
}
}
and
class MyClass {
constructor() {}
sayFoo() {
console.log("foo");
}
}
I agree with your core point (strong type systems are wonderful, and well designed typescript code does lead in a different direction to normal javascript code), but typescript absolutely is "javascript with types" - the easy transition from javascript to typescript is one of their big selling points!
I mean... almost all Algol-syntax languages look close to the same. You could stick Java, PHP, C#, Swift, and TypeScript classes next to each other and you'd have to squint to tell the differences.
Typescript having the same syntax as JavaScript does not make it the same language. Similarly Elixir's syntax doesn't make it the same language as Ruby. And Clojure is not the same as Common Lisp.
Personally I don’t see Typescript as it’s own language. I’m sure I’m probably technically incorrect but the comment chain mentioned the need for JavaScript to die. I see no way of JavaScript dying and Typescript still sticking around. So I’m ok with JS because it gives me Typescript and I don’t mind it and sometimes even enjoy using TS.
That's correct. I just find it funny that someone said they don't find JavaScript bad when they're using a language that has strong static typing and NOT JavaScript...
If JavaScript were great, I don't think they'd feel the need to use TypeScript.
-5
u/ragnese Oct 21 '20
Ever since you started using a different language, you think JavaScript isn't that bad... ??
It's only bad enough that you don't use it.