4 ms·
TypeScript is deliberately not a language in the sense that you mean, and this is very much a load bearing part of the design and why it was successful. Many ot
by rictic 5y ago
TypeScript is deliberately not a language in the sense that you mean, and this is very much a load bearing part of the design and why it was successful. Many other languages have tried what you're suggesting, most infamously Dart, and all crashed aground on the problem of interoperating with the existing ecosystem.
TypeScript is best understood as a very advanced linter for JavaScript, not a separate language with its own semantics that happens to compile to JavaScript.
This has many consequences. For example, its type system is unsound to a profligate degree compared to most other typed languages. As a result, it is common for the type system to be wrong about the type of a variable, meaning that any runtime use of type information would have to also cope with being wrong, e.g. by inserting runtime type checks. Runtime type checking for structurally typed interfaces is heinously slow, as you have to type check every field of every transitively reachable interface.