-

1、node环境自备

2、全局安装typescript

 npm install -g typescript

3、在VSCODE编辑器中新建TS文件夹

  • 创建src根目录
  • 创建app.ts
  • 编写你的TS代码

(1)通过命令行运行TS文件

tsc ./src/app.ts --outFile ./dist/app.js
tsc ./src/* --outDir ./dist --watch

(2)可以通过tsconfig.json配置文件运行

  • tsc --init
  • 修改配置文件
"outDir": "./dist",
"rootDir": "./src"
  • 启动
tsc --watch

在app.ts中编辑的ts代码会实时的编译到dist/app.js中

 

 

 

 

-

相关文章:

  • 2021-07-21
  • 2022-12-23
  • 2022-12-23
  • 2021-09-18
  • 2022-12-23
  • 2021-09-26
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-05-25
  • 2021-11-22
  • 2022-12-23
  • 2021-12-03
  • 2021-07-14
相关资源
相似解决方案