运行typescript
1. 安装
- npm install -g typescript
- cnpm install -g typescript
- yarn add global typescript
验证安装成功:
重新打开命令终端 输入tsc -v
2. 运行typescript
tsc greeter.ts
会生成相应的es5js代码
3. 使用vscode自动编译.ts文件
- tsc --init 生成tsconfig.json
- 将tsconfig.json中的outDir路径改成需要的路径,我改成了“./js”
- 监视ts文件
点击Terminal > run task > tylpescript > tsc: watch -tsconfig.json