TypeScript: Types

Understanding the basic “Built-in Data Types” provided by TypeScript

In this lesson, we are going to learn about the building blocks of TypeScript’s type system. Here, we are mainly going to focus on the primitive data types provided by the TypeScript.

Uday Hiwarale
JsPoint
Published in
10 min readMay 15, 2020

--

(source: unsplash.com)

In TypeScript, the type of a variable is denoted using :<type> annotation where <type> is any valid data type. Unlike programming languages like C and C++ in which the type of a variable is declared before the variable name like int a or void someFunc(), in TypeScript, the type annotation comes after the variable name, also known as the postfix type notation.

let fruit:string = 'Mango';

In the above program, :string signifies that the variable fruit contains string data. If you are claustrophobic, you can add space between the colon and the data type, like let fruit: string which is generally preferred.

(intro.ts)

In the above example, we have defined a few variables. Some of these variables have an initial value such as age, car and canDrive

--

--