Tags

TypeScript Interfaces

In this tutorial, we will learn about TypeScript Interfaces. An interface defines what members (properties, functions) an object must have. For example, we define that a interface ICar has two properties 'make', and 'name' then all objects which implements this interface must have these two properties. In TypeScript interface, we can define only properties and functions signatures. We do not p...

Continue Reading

TypeScript Rest Parameters

TypeScript Rest parameters allows a function to take unlimited parameters. Rest parameters are used when we are designing a function and we do not know how many parameters are required. Rest parameters feature group parameters into a single variable and we can access parameters inside a function just like an array of parameters. There is only one rest parameter allowed in a function. Syntax...

Continue Reading

Typescript Optional Parameters

TypeScript is a strong typed language. When we declare parameters for a function then all the parameters are required and client has to pass values to every parameter. When client has no value for any parameter then he can pass null value. TypeScript provides a Optional parameters feature. By using Optional parameters featuers, we can declare some paramters in the function optional, so that clien...

Continue Reading

TypeScript Switch Case

Switch case statement is used when we have to choose between different blocks of code based on an expression. It replaces the need of multiple if...elseif conditions and provides more clean code. Switch evaluates an expression and then match with different case clauses. If any value matches with case clause then it execute associated code block statement else execute default case statement. ...

Continue Reading

TypeScript Union Type

TypeScript Union Type is a hint of possible data types of a variable. We used union types when we are not sure about the possible variable data type but we know about possible data types are limited. For example we have a variable discount. We know a discount variable is always be a number data type. But we are using external JavaScript libraries and that libraries can send discount value in a...

Continue Reading

Typescript Data Types

In this TypeScript tutorial, we will learn about TypeScripts data types. Data types helps you to write code just like you write in other OOPS languages like C# and Java. Data Types provides strongly typed code. A strongly typed code means all variables data types are known at compile time. Strongly typed code helps compiler to throw error when it's see a mismatch of assigned variable values li...

Continue Reading

TypeScript Environment Setup

There are two popular options available for writing TypeScript code: Use an online playground Use Visual Studio 2015 and above Online Playground Typescriptlang.org provides a web page where we can immediately write and see javascript output in a web page. You can click on Playground link. In the left section of page we can write our TypeScript code and right section automat...

Continue Reading

Introduction - TypeScript Tutorial

JavaScript is everywhere. It is used in every website you visit. JavaScript is an easy language to learn and program. But difficulty comes when we have to write large and complex programs. The first challenge we face is that JavaScript is an interpreted language and does not compile. We does not know the error in program until runtime. Second challenge, JavaScript is not an object oriented langu...

Continue Reading