我希望使用内联样式前缀,如:

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

...

var prefixer = new InlineStylePrefixer(userAgent);


...
var _style = InlineStylePrefixer.prefixAll(style);

如何在声明模块中导出构造函数?
declare module "inline-style-prefixer"{
    export function InlineStylePrefixer(useagent:string):void; // error
    export function prefixAll(style:Object):Object;
}

最佳答案

你会做两个/三个声明:

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

当有一个类和一个同名的模块时,该模块与该类合并。

关于typescript - 如何在声明模块中导出构造函数,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/34384093/

10-13 02:37