sudo npm i -g typescript
- check version:
tsc -v
-
tsc [filename]
-
after file being compiled, a
js
version of the file is being created: -
the compiled
js
file is converting by default to ES5:
tsc --watch [filename]
-
tsc --init
=> createstsconfig.json
-
under
compilerOptions
, change thetarget
toes6
-
run
tsc
again (no filename needed) and newjs
files is being created:
- the
typescript
files are in a separated source folder and the javascript files in adist
folder - have to specify
"outDir": "./dist"
and"rootDir": "./src"
check how the enum
is being compliled into in the js
file!
- NOT used with primitives
- used with objects
- optional properties
readonly
properties