How do you define an interface in TypeScript so that this type can be called continuously in the form of a function?

topic description

how to improve the declaration of Calculator.

sources of topics and their own ideas

online search for one of the TypeScript interview questions, but I don"t know how to end it.

related codes

interface Calculator {
    ...
}
 
let calcu: Calculator;
calcu(2).multiply(5).add(1)

what result do you expect? What is the error message actually seen?

ask for answers!

Jan.08,2022

interface Calculator {
  (num: number): Calculator;
  multiply(num: number): Calculator;
  add(num: number): Calculator;
}
Menu