Data Types

Details:

Variables

let identifier: type = value;

// type inference
let identifier = value;

Example

let isDone : boolean = false;

let roll: number = 6;

let fullName: string = "TAREQ HASSAN";

let fooList: number[] = [1, 2, 3];
let fooList: Array<number> = [1, 2, 3];

let coordinate: [string, number] = [14, 75];

enum Color { Red = 1, Green, Blue };
let c: Color = Color.Green;

let notSure: any = 4;

function warnUser(): void { }

let nuru: null = null;

let unDefu: undefined = undefined;

function error(message: string): never { throw new Error(message); }

See: https://www.typescriptlang.org/docs/handbook/variable-declarations.html#variable-declarations

Constant

const PI = 3.1416;

See: https://www.typescriptlang.org/docs/handbook/variable-declarations.html#const-declarations