No matter how hard I look, I cannot figure out the correct way to combine return type annotation with fat arrow syntax.
class BasicCalculator{
value:number;
constructor(value:number=0){
this.value=value;
}
add= (operand:number)=>{ // CAVEAT how to add return type???
this.value+=operand;
return this;
}
subtract= (operand:number)=>{
this.value-=operand;
return this;
}
multiply= (operand:number)=>{
this.value*=operand;
return this;
}
divide= (operand:number)=>{
this.value/=operand;
return this;
}
}
I attempted:
add= (operand:number)=>number { ....
but it just won't work as expected.