How to define static property in TypeScript interface

前端 未结 14 1278
你的背包
你的背包 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:03

    If you're looking to define a static class (ie. all methods/properties are static), you can do something like this:

    interface MyStaticClassInterface {
      foo():string;
    }
    
    var myStaticClass:MyStaticClassInterface = {
      foo() {
        return 'bar';
      }
    };
    

    In this case, the static "class" is really just a plain-ol'-js-object, which implements all the methods of MyStaticClassInterface

提交回复
热议问题