TypeScript - rohit120582sharma/Documentation GitHub Wiki

Introduction

TypeScript is a primary language for Angular application development. It is a superset of JavaScript, essentially it is JavaScript with some new features. It includes many improvements over JavaScript.

Allows static typing that means you can define a type of your variable. JavaScript lacks strong typing which means some errors might only pop-up at runtime. Static typing means that a lot of these basic errors can be caught at the compile time by the compiler.

It also supports Interface, enum, class, ...

Browsers cannot execute TypeScript directly. Typescript must be "transpiled" into JavaScript using the tsc compiler, which requires some configuration. npm install typescript -g is npm command to install typescript compiler.

References

Overview

Configuration

The tsconfig.json file specifies the root files and the compiler options required to compile the project.

To enable experimental support for decorators, you must enable the experimentalDecorators compiler option.

{
	"compileOnSave": false,
	"compilerOptions": {
		"target": "es5",
		"module": "commonjs",
		"moduleResolution": "node",
		"sourceMap": true,
		"declaration": false,
		"emitDecoratorMetadata": true,
		"experimentalDecorators": true,
		"typeRoots": [
			"node_modules/@types"
		],
		"types": [
			"jasmine",
			"node"
		],
		"lib": [
			"es2017",
			"dom"
		]
	},
	"include": [
		"./src/**/*"
	],
	"exclude": [
		"node_modules",
		"./src/**/*.spec.ts"
	]
}