Convert a string to number

JavaScript version
const toNumber = (str) => +str;
TypeScript version
const toNumber = (str: string): number => +str;
Examples
toNumber('42'); // 42