typescript void code example

Example 1: typescript integer

// There is no int type, use number
const myInt: number = 17;
const myDecimal: number = 17.5;

Example 2: how to declare a boolean in typescript

let isDone: boolean = false;

Example 3: void in ts

// Similar to languages like Java, void is used where there is no data. 
// For example, if a function does not return any value then you can 
// specify void as return type.
function sayHi(): void { 
    console.log('Hi!')
} 

let speech: void = sayHi(); 
console.log(speech); //Output: undefined