ts 在Function上创建静态属性和方法

interface IMessage {
  (value: any): void;
  success(): void;
  error(): void;
  version: string;
}

const Message: IMessage = function Message(value: any) {
  console.log(value);
};

Message.version = "1.0.0";

Message.success = function () {
  console.log("success.");
};

Message.error = function () {
  console.log("error.");
};

Message("hello world.");
Message.success();
Message.error();
posted @ 2020-12-08 09:54  Ajanuw  阅读(1145)  评论(0编辑  收藏  举报