interface 定义函数

  1. interface IFun {
  2. (num: number): void;
  3. }
  4. let ifun: IFun = (num: number): void => {};

type 定义函数

  1. type TypeFun = (num: number) => void;
  2. let tfun: TypeFun = (num: number): void => {};

对象定义函数

  1. interface IObj {
  2. ofun: IFun;
  3. }
  4. let obj: IObj = {
  5. ofun: (num) => {},
  6. };
  7. obj.ofun(123);