Over the past day, I have dedicated a significant amount of time to understanding:
- the inner workings of Visual Studio Code
- the ins and outs of TypeScript
- the functionality of the TypeScript Compiler (
tsc
) - how these three components intertwine with each other
In less than 24 hours (!), I successfully managed to write some basic TypeScript code and compile it into Javascript.
My excitement was slightly dampened when I realized that the TypeScript Compiler (tsc
) not only compiled the static type labels but also transpiled:
const
to:
var
I expressed feeling dampened, but truthfully, I was actually mildly shocked.
Later on, I discovered that the default transpilation target for tsc
is ECMAScript 3.
It seems that I can maintain my const
declarations constant by using the --target
flag when invoking tsc
:
tsc my-first-typescript.ts --target es6
However, constantly having to include --target es6
(or --target es11
) every time I call upon tsc
is not ideal.
Is there a method to establish the default transpilation target version for tsc
so that it does not automatically revert to outdated javascript practices?