how to export constructor in a declare module

后端 未结 2 2002
轻奢々
轻奢々 2021-02-13 18:57

I want use inline-style-prefixer like:

var InlineStylePrefixer = require(\'inline-style-prefixer\');

...

var prefixer          


        
2条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-02-13 19:26

    You'd do two/three declares:

    declare class InlineStylePrefixer {
      constructor(useagent: string) {}
    }
    declare module InlineStylePrefixer {
        export function prefixAll(style: Object): Object;
    }
    declare module "inline-style-prefixer" {
      export = InlineStylePrefixer;
    }
    

    When you have a class and a module with the same name, the module is merged with the class.

提交回复
热议问题