TypeScript is the programming language which is the superset of JavaScript and compiles to plain JavaScript. TypeScript is also the general purpose object-oriented programming language with classes, object, and interfaces. The framework of JavaScript such as angular 2.0 is in TypeScript. JavaScript on the side of server and client complies the program created in TypeScript. Following programming cheat sheet helps a programmer to learn the syntax and various methods of the TypeScript programming language. You can find freelancers who know TypeScript language, and you also get certified freelancers for this language.

Simple Program of TypeScript

var message:string = “Hello World”


Variable in TypeScript

The variables in the TypeScript follow the same rules of JavaScript. The variables in the TypeScript should not contain the spaces and special character except the underscore (_) and the dollar sign. The syntax of the variable in TypeScript includes the colon (:) after the variable name and also use the var keyword for a declaration of a variable.

Syntax for variable

Var name: string;    In this syntax, the type of the variable is the string type, and the value of the variable is undefined.

var name: string = “Kitty” In this type variable store the particular name that is “kitty.”

Operators in TypeScript

Operators are the symbols that tell the compiler to perform the specific task. The operator works on data which is known as an operand. Following are the types of operators in Typescript.

Arithmetic Operators

Relational operators

Logical Operators

Bitwise Operators

Assignment Operators

String Operator

Type Operator

Conditional Operators

Function in Typescript

The function is the block of code written in the program, and that block of code is maintainable and reusable in the whole program. The function is the collection of statements that perform the specific task.

Syntax for defining function

function  function_name() {

// function body


Syntax for calling the function


Syntax for returning function

function function_name():return_type {


return value;


Syntax for parameterised function

function func_name( param1 [:datatype], ( param2 [:datatype]) {


Numbers in TypeScript

The number class act as the wrapper and allows manipulation of numeric literals as were objects.

Syntax for Numbers

var var_name = new Number(value)

String in Typescript:

The object of the string will work with the characters. The primitive data types are wrap with the helper methods.


var var_name = new String(string);

Following are the string method in TypeScript.

String Constructor Method

var str = new String( “This is string” );

console.log(“string constructor is:” + str.constructor)

String Length Method

var uname = new String(“Kitty Gupta”)


console.log(“Length “+uname.length)

String Prototype Method

function employee(id:number,name:string) {

this.id = id

this.name = name


var emp = new employee(121,”Kitty”)


console.log(“Employee ‘s Id: “+emp.id)

console.log(“Employee’s name: “+emp.name)

console.log(“Employee’s Email ID: “+emp.email)

Array in TypeScript

The array is the collection of similar type of data structure. The array in the TypeScript allocates the sequential memory block. For declaration of an array use the var keyword. The unique integer called the subscript/index of the element recognizes the array elements.  You can find freelancers who have knowledge of TypeScript language, and you also get certified freelancers for this language.

Syntax for the declaration and initialization of array

var array_name[:datatype];        //declaration

array_name = [val1,val2,valn..]   //initialization

Tuples in TypeScript

In Typescript programming language tuples is the term which stores the multiple fields of different types. Through tuples you can also pass the parameters to functions.


var tuple_name = [value1,value2,value3,…value n]

Union Types in TypeScript

Union types denote the values that can be one of the several types. The two or more data types are combined using the symbol(|) to denote the Union Type

Syntax for Union Type


Interface in TypeScript

The interface is the contact between the entity. The members of the interface are methods, events, and properties. \

Following are the syntax for the interface.

interface interface_name {


Modules in TypeScript

The modules of TypeScript are of two types.

Internal module

The internal modules combined classes, functions, methods, and interfaces into the single unit and exported in another module. Following are the syntax for the internal module.

Syntax For Internal Modules.

module Freelancegig {

export function add(x, y) {




External Module

This module is used to define load dependency between multiple external js files.

export interface SomeInterface {

//code declarations


Summary: This article is on the TypeScript programming cheat sheet.  The TypeScript programming language is easily understandable if you know JavaScript programming language. The above programming cheat sheet helps a programmer to learn the syntax and various methods of the TypeScript programming language.