属性类型与函数类型的混合,可以同时定义形参、返回值、函数的属性

  1. interface MyInterface {
  2. ( params: type ): type;
  3. property: type;
  4. method(): type;
  5. }
  • 使用该接口时,赋值的函数必须有规定的属性

示例

  1. interface MyInterface {
  2. (): number;
  3. count: number;
  4. }
  5. const countFunc = (): MyInterface => {
  6. const c = (): number => { ++c.count }
  7. c.count = 0
  8. return c
  9. }
  10. const addCount: MyInterface = addCount()