This is a basic project to study typescript.
To start the playground project please run below command.
- Install project requirements.
npm install
- Start project on localhost:3000
npm start
To install the typescript please run below command. It will install typescript globally to your machine.
npm install -g typescript
If you don't have node js on your local machine first install node js from below link.
https://nodejs.org/de/download/
To compile your typescript files please run with below command.
tsc filename.js
As you can see we have 2 folders in the project which are src and dist.
src folder contains our ts file and dist folder contains our output js files.
See examples in the union-alias-literal.ts
See examples in the functions.ts
See examples in the unknown-never.ts
Run your typescript command with --watch
or -w
keyword to compile every changes in your ts file.
Instead of
tsc app.ts
run
tsc app.ts -w
Create tsconfig.json file with below command.
tsc --init
After creation of tsconfig file you can run below command to compile all ts files in your project even with watch
feature.
tsc -w