我在 typescript 中有一个像这样的模块:
let function test(){
//...
}
export default test;
我希望 tsc
将其编译为如下所示:
let function test(){
//...
}
module.exports = test;
但是,我发现它是这样编译的:
let function test(){
//...
}
exports.default = test;
所以我必须这样要求:
const test = require('xxx').default;
那么如何解决这个问题呢?
最佳答案
So how to solve this?
使用export =
。
固定代码
let function test(){
//...
}
export = test;
关于javascript - Typescript 中的模块系统,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47447038/