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.
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
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.
In the above example, we have defined a few variables. Some of these variables have an initial value such as
canDrive while others such as
person do not.
null as the value for a variable even though its type might say something else. For example,
person variable can hold only
string data but its value is
undefined at the beginning. Similarly,
age can hold only
number data but it was initialized with the
You can also override a variable with
null value after it declared at any given moment. TypeScript considers
null as the
Null values or empty values. Though
undefined are types in itself as we will learn in a bit, TypeScript doesn’t allow a variable to be
Null (empty) by default.
To disable this behavior, we need to set
strictNullChecks compiler-option to
true. This will instruct the TypeScript compiler to disallow variables to hold
null value. In this mode, the variable must hold a value of its type before consumption.
Looking to **hire NodeJS Developer**[https://www.dataeximit.com/node-js-development/](https://www.dataeximit.com/node-js-development/ "https://www.dataeximit.com/node-js-development/") to build a perfect back-end to your website or...
Build your eCommerce project by hiring our expert eCommerce Website developers. Our Dedicated Web Designers develop powerful & robust website in a short span of time.
Things have changed pretty fast from what was a decade ago for web development and the facts are totally mind-blowing. I mean a web developer now makes mobile apps, desktop app, backend API, games and so much more.
This article covers A-Z about the mobile and web app development process and answers your question on how long does it take to develop/build an app.