用Typescript 开发 node.js (方法2)
参考文档: https://blog.csdn.net/haodawang/article/details/78669768
1. 首先我们需要安装typescript的tsc编译器 cnpm install --save typescript
2. 执行命令 npm init
3. 执行命令 tsc --init
4. 修改 tsconfig.json
"outDir": "./dist",
"rootDir": "./src",
5. 添加文件 src/main.ts
class Person { constructor(name: string) { console.log(`Hello Person constructor ${name}`); } } let person = new Person('赵钱')
6. 运行编译命令 tsc (或者 tsc -w 带监视功能)
7. 运行程序 node dist/main.js