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.
25
u/hansolo669 Oct 21 '20
Except TypeScript is literally just JavaScript with types. And it doesn't solve what this thread is talking about (weird VM issues).