'TypeScript two digits addition returns a string concatenation

const x = 1;
const y = ('3' as unknown) as number;

let add = (num1: number, num2: number)=> {
    return num1 + num2;
}

console.log(add(x, y));

// prints 13

Where it is supposed to print 4 as "const y" is converted to "number" type



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source