module.exports 从 javascript 到 typescript 的转换

Say*_*hoo 1 javascript node.js express typescript

我有 Node-express 代码,其中使用 module.exports 导出模块。例如,导出一个函数,则写为 module.exports = functionName。现在代码将转换为打字稿。如何替换打字稿中的 module.exports ?

小智 5

只需使用export后跟典型的声明,无论它是constfunctioninterfaceenum,只要你能想到的。

export const myTestConst = () => console.log('hello world');
Run Code Online (Sandbox Code Playgroud)

请参阅https://www.typescriptlang.org/docs/handbook/modules.html