CodesJava

Easy learning with example program codes

TypeScript module tutorial


TypeScript module:

A module refers to a set of standardized parts or independent units that can be used to construct a more complex structure. TypeScript modules provides a way to organize the code for better reuse.

Syntax:

export interface InterfaceName { 
   //Block of statements 
}

The import keyword is used to use the declared module in another file.

import testInterfaceRef = require(“./InterfaceName”);

Example:

IShowDetails.ts

export interface IShowDetails { 
   display(); 
}

Student.ts

import showDetails = require("./IShowDetails"); 
export class Student implements showDetails.IShowDetails { 
   public display() { 
      console.log("Student Details"); 
   } 
}

Teacher.ts

import showDetails = require("./IShowDetails"); 
export class Teacher implements showDetails.IShowDetails { 
   public display() { 
      console.log("Teacher details."); 
   } 
}

TestShape.ts

import showDetails = require("./IShowDetails"); 
import student = require("./Student"); 
import teacher = require("./Teacher");  
 
function showAllDetails(detailsToShow: showDetails.IShowDetails) {
   detailsToShow.display(); 
} 
 
showAllDetails(new student.Student()); 
showAllDetails(new teacher.Teacher());


TypeScript Tutorial

TypeScript Overview.
Typescript vs Javascript.
Typescript let vs var.
TypeScript Hello World.
Typescript Data Types.
Typescript Variable Declaration.
TypeScript operators list.
TypeScript Arithmetic Operators.
TypeScript Comparison Operators.
TypeScript Bitwise Operators.
Typescript Logical Operators.
TypeScript Assignment Operators.
Typescript Conditional Operator.
Typescript String Operator.
Typescript typeof Operator.
TypeScript control statements.
TypeScript Switch Statement.
TypeScript for loop.
TypeScript for in loop.
TypeScript while loop.
TypeScript do while loop.
Typescript for loop break.
TypeScript for loop continue.
Typescript function.
Typescript returning function.
Typescript parameterized function.
Typescript function optional parameter.
Typescript rest parameters.
Typescript default parameters.
Typescript anonymous function.
Typescript function constructor.
Typescript Arrow/Lambda function.
Typescript function overloading.
TypeScript number object.
TypeScript string object.
TypeScript boolean object.
TypeScript date object.
TypeScript math object.
TypeScript array object.
TypeScript tuples.
TypeScript union type.
TypeScript interface.
TypeScript interface inheritance.
TypeScript interface multiple inheritance.
TypeScript class.
Typescript class inheritance.
Typescript class interface.
TypeScript abstract class.
TypeScript object.
TypeScript duck typing.
TypeScript NameSpace.
TypeScript Multi-file namespaces.
TypeScript module.
TypeScript ambient module.


Copyright © 2018 CodesJava DMCA.com Protection Status SiteMap