How to define static property in TypeScript interface

前端 未结 14 1243
你的背包
你的背包 2020-11-28 05:49

I just want to declare a static property in typescript interface? I have not found anywhere regarding this.

interface myInterface {
  static         


        
14条回答
  •  孤城傲影
    2020-11-28 06:00

    Static properties are usually placed on the (global) constructor for the object, whereas the "interface" keyword applies to instances of the object.

    The previous answer given is of course correct if you are writing the class in TypeScript. It may help others to know that if you are describing an object that is already implemented elsewhere, then the global constructor including static properties can be declared like this:

    declare var myInterface : {
      new(): Interface;
      Name:string;
    }
    

提交回复
热议问题