gpt4 book ai didi

typescript - 如何在声明模块中导出构造函数

转载 作者:搜寻专家 更新时间:2023-10-30 20:33:10 26 4
gpt4 key购买 nike

我想像这样使用内联样式前缀:

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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com