如何在Typescript中声明NodeJs模块?

时间:2013-03-19 18:30:35

标签: node.js typescript

我的消费节点代码如下所示:

var helloworld = require('helloworld');
helloworld.sayhello();

使用Typescript的优点,我如何声明模块导出sayhello()函数?

1 个答案:

答案 0 :(得分:3)

<强> helloworld.ts

export function sayhello() {
    console.log('hello, world!');
}

请注意,您不会编写包含module块(文件本身就是模块)。

相关问题