Hello Friends đź‘‹,

Welcome To Infinitbility! ❤️

TypeScript haven’t any new or specific way to convert string to a number, we have to do the same like javascript.

JavaScript provide multiple way to convert string to number, we can use parseInt(), parseFloat(), and unary + operator.

I will recommend the unary + operator because is the fastest way to convert a string to a number.

let see how we can use javascript string to number conversion ways in typescript.

unary + operator

let x: string = "32";
let y: number = +x; // 32

parseInt

let x: string = "32";
let y: number = parseInt(x); // 32

parseFloat

let x: string = "32.43";
let y: number = parseFloat(x); // 32.43