|
|
|
|
|
by BoorishBears
1709 days ago
|
|
This comment would be a lot shorter if you assumed I meant Typescript in response to a Typescript article... But I digress, the point is in my experience Typescript is very good about catching footguns left around by ECMAScript. So I'm surprised there isn't some sort of catch for this as written in the article maybe behind a config flag, not by rewriting the definition. |
|
You misunderstand TypeScript.
They cannot 8and will not) change the "Javascript" in Typescript. "const" is a keyword with a meaning defined by the ECMAscript standard.
Typescript IS Javascript. All they do is add type annotations. Only some old non-essential features like namespaces and enums need to be transpiled, and "enums" really is not much and should actually be handled by whatever minifier and bundler/packager you use. Other than that, if you removed the type annotations you are left with 100% ECMAscript.
Typescript was meant to be just a type-annotation extension and explicitly made the decision that the code itself would always be stock-standard Javascript.
Arguably, it was a bad design decision that now confuses lots of people about the nature of Typescript by bundling type-checking and transpiling to some target (originally for older runtimes that did not understand es2015 or were lacking some feature available in the latest JS runtimes and ECMAscript standard).
It is therefore not a surprise at all that Typescript did not make "const" into something else. The basis always is the ECMAscript standard.