While assigning variable type as Number got the following error in TypeScript, Operator ‘+’ cannot be applied to types ‘Number’ and ‘Number’

const foo = (a:Number,b: Number) => {
  return a+b;
}

So what’s wrong with the above code .Type of a and b should be number and not Number.

// ## Solution
const foo = (a:number,b: number) => {
  return a+b;
}

Number in typescript is a constructor which creates Number objects.

let num = new Number(10);

And the Number object has a couple of helping methods like, toExponential,toLocaleString etc.