Typescript is not really a superset of JavaScript
Let's consider T(ts: string): string
, the function compiling TypeScript code to JavaScript. If TypeScript is a superset
of JavaScript, then, for all valid Javascript expression js
, T(js) === js
as the compiler should consider valide JavaScript
expression as valid TypeScript expression that do not need to be changed during compilation (of course, we consider that the
JavaScript version of the input of T
is the same as the output one).
In order to demonstrate that TypeScript is not a superset of JavaScript, one only need to find a single JavaScript expression
jsbreak
as of T(jsbreak) !== jsbreak
.