1) How to cast in TypeScript ?

Type assertion should be used.
let array: any = [1,2,3,4,5];
let arrayLength: number = (<Array[]>array).length;


let array: any = [1,2,3,4,5];
let strLength: number = (array as Array[]).length;

Both variants are equivalent, however if you using typescript in JSX as keyword is more convenient.

2) How to check object type?

Using Javascript instanceof operator
class Animal{
  private name:string;
let bird=new Animal();
console.log(bird instanceof Animal)// true

3) How to install TypeScript ?

Typescript is available in NPM and Yarn
npm install -g typescript

4) How to compile single file ?
//helo.tsconsole.log('Hello world!')
$  tsc hello.ts

5) How to declare array ?

Array is one of basic types, to declare it following syntax should be used:
let array: number[] = [1, 2, 3];
interface Person{
let employees:Array<Person>=[{name:'John Doe'}] //declaring array of objects

6) How to check whether variable is undefined and/or null ?

Most simple way, is to use ( something == null ) operator. It return true, if something is null or undefined. Also ! operator can be used.
let obj:any={};
let nullValue:any=null;
let undefinedValue=obj.someProp;

if(!nullValue || !undefinedValue){

7) How to create enum like type in TypeScript?

Using enum keyword. Enum body consists of zero or many elements. Each element has name & value. Value can be declared as constant or computed.
enum Status {

8) How to override method?
Just implement needed method in derived class. Method in base class should have public or protected modificator.
class Shape{
  public paint(){
    throw new Error("Abstract method execution.")
class Square  extends Shape{
  private height:number;
  constructor (height:number){
let obj:Shape=new Square(5);
obj.paint(); // |Square| 

9) How to debug TypeScript?

There is no recommended way to do it. Most popular is to use ts-node library, which give you ablity to require *.ts files directly in JavaScript file or run ts file. Also using V8 Inspector Protocol we can debug Node.js application in Chrome, using powerful chrome dev tools.

$ ts-node script.ts

10) How to import module?

Any file that containing import/export keyword is considered as module. There is two types of exports: default and named. To import default export write this : import * as Module from './SomeModule'. To import named export - import {SomeFunc} from './SomeModule'.
export default class MyClass{
//Module B
import MyClass from './ModuleA'
import * as moment from "moment";

11) How to name interface?

According to official coding guidelines, you should use PascalCase for types names. Also don't use "I" prefix in interface names. For interface implementation Impl suffix can be added(something like WritableImpl)

12) What is union type ?

Variable should be declared with union type if it can be set with values of different types. It can be usefull when you need to return correct result or null value, for example in find function.

13) What is decorator and how they can be used ?

Decorator is a function, which provides a way to add annotation and meta-programming syntax to class and member-functions declaration. Decorator can be attached to a class declaration, property declaration, method, get/set accessors, or parameter. Syntax is very simple, similar to Java anotations.
export default class MyClass{
  private id:number;

14) How to access member of super class?
To call base class constructor just run super(). To call base class method use following syntax:
class Abstract{
  public method(){
class Concrete  extends Abstract{

15) How to use forEach and for..of in TypeScript?

There is no difference between how to use in JavaScript, except you can specify type for array elem. Also there will be compiler error if you try run forEach method for object or string.
let notArray='dsd';
notArray.forEach(e=>{}) // Compilation error - Unresolved function forEach
let array:number[]=[1,2,3];
array.forEach(e=>e.toExponential(2)) // Compiler knows that has number type 

16) What types of access modificators are available ?

There is three types: public,private,protected. By default all class property & methods are public, but it's better to add this explicitly, in order to make code more readable. Use protected modificator if you want grant access to all descendant classes, this is useful in complex OOP design. Finally, use private to encapsulate details for implementation, it helps to protect class client from it's inner structure changes. Note that, all this access checks will work only at compile time, because JS don't support access modificators.

17) What is duck typing ?

Duck typing consider two object have the same type, if they have same set of properties. Declaring object with literal is equal to creating object with new operator

18) What is generics ? How to use them?

Generic is a some generalized type, which can substituted by any concrete type like string or number. Generics allow to write universal function, with type safety, without using "any" type. There is generic functions,classes, or interfaces, for example you can write Container<T> class, which implement basic collection operations, regardless type of stored elements.
function loggingObject<T>(arg: T): T {
     return arg;

19) How to use namespaces with TypeScript external modules?

Namespaces helps organize your code by grouping logically-related types,classes,functions, also using namespaces prevent name conflicts in different modules. External modules are already exist in a FS, so we have to load them by path and filename, so there's a logical organization scheme for us to use. Name conflicts can be solved by using 'import as'

20) How to pass options to TypeScript compiler?

Through command line arguments or tsconfig.json file. If file tsconfig.json located in some directory, that mean's this root of TypeScript project. There are such options available: compilerOptions,files,typeRoots, include, exclude.

21) There is some way to automatically recompile project if some file changed?

Yes, run tsc command with -w argument, also pass --no-initial-compille option if you want only watch changes.

22) How to use JSX in TS project?

To use JSX you need, save your code in files with *.jsx extension and enable jsx option in tsconfig.json. There is three JSX modes react,preserve, react-native.