This guide assumes you have basic knowledge of how JavaScript works, so it will not go into details with explaining certain JavaScript topics.
- an extra compliation step.
- strong / static typing
- type definitions for popular JS libraries
- encapsulation - the ability to define data and a set of functions into a single component
- private / public member variable decorators.
npm install --global typescript
This will install TypeScript as a global module, so you can use it no matter what directory you are in. You can use the command tsc filename.ts
to compile the TypeScript file into JavaScript.
tsc --init
This command will create a tsconfig.json
file in the root of the project folder. It specifies the global TypeScript project settings and compiler options. It will create a file similar to the file below:
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"strict": true
}
}
This has all the comments removed, but you can checkout the complete generated tsconfig.json
here
You can checkout Compiler Options for more information.
You can create multiple tsconfig.json
files within the same project directory, so different sub directories will use different compiler options.