Looking for a way in Typescript to define an interface Calculator that allows for concatenation capabilities?
interface Calculator {
...
}
let calcu: Calculator;
calcu(2).multiply(5).add(1)
I attempted the following:
interface Calculator {
(num: number): Calculator;
multiply(num: number): Calculator;
add(num: number): Calculator;
}
Encountered an error stating that calcu is not instantiated:
Variable 'calcu' is used before being assigned
My question now is how can I define the interface Calculator and successfully instantiate calcu.