Why?
ref: [
{
value: Number
date?: Date
}
]
total() {
var total = 0
for (var ind = this.ref.length - 1; ind >= 0; ind--) {
total += this.ref[ind].value
}
return total
}
This is totaly vaild in JS, should be in typescript too
You want number (all lowercase) not Number. number is the primitive type, whereas Number is a description of the shape of instances of Number and number itself.
See a more detailed response here: https://github.com/Microsoft/TypeScript/issues/2624#issuecomment-89914698
Or @danquirk's response here: https://github.com/Microsoft/TypeScript/issues/2031#issuecomment-74329927
Note that #2361 aims to address this.
Most helpful comment
You want
number(all lowercase) notNumber.numberis the primitive type, whereasNumberis a description of the shape of instances ofNumberandnumberitself.See a more detailed response here: https://github.com/Microsoft/TypeScript/issues/2624#issuecomment-89914698
Or @danquirk's response here: https://github.com/Microsoft/TypeScript/issues/2031#issuecomment-74329927