In this TypeScript example let us create two variables using explicit casting keywords. When a variable has been cast it will become a single type which means if that variable has been cast to type number then it will not be able to change to another type again except if that variable has been cast to type ‘any’ then you can assign all type of variables to it because type any simply means this variable can be any type as you wish.
Example: Let’s create two TypeScript variables and then find out their total.
var item1 = <number> 1 var item2 = 2 as number console.log(item1+item2) /*3*/
As you can see there are two TypeScript methods that can be used to explicitly create a variable, one is using the <> and another one is using the ‘as’ keyword.