Data types: Strings, Numbers, Booleans

Description

TypeScript infers data types on variables declared. It can be done like this;

Example 1: Strings

let name = 'Peace';
//TypeScript automatically infers the type of string on the name variable because the value is a string. If the value of the name variable is changed to a number or a       different data type, an error will be produced.

Example 2: Numbers

let age = 3;
//TypeScript automatically infers the type of number on the age variable because the value is a number. If the value of the age variable is changed to a string or a        different data type, an error will be produced.

Example 3: Boolean

let isLoggedIn = true;
//TypeScript automatically infers the type of boolean on the isLoggedIn variable because the value is a boolean. If the value of the isLoggedIn variable is changed to a number  or a different data type, an error will be produced.

No Comments Yet