Search code examples
typescript

The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type


1    interface Dimensions {
2        width: Number,
3        height: Number
4    }
5
6    function findArea(dimensions: Dimensions): Number {    
7        return dimensions.height * dimensions.width;
8    }

line 7, red squiggly lines under dimensions.height and dimensions.width

The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.

I'm trying to eradicate red squiggly, but I'm stumped as to why the typescript compiler is giving me an error. As far as I can tell, width and height are of type Number.


Solution

  • Number should be lowercase: number.