在vscode中直接运行ts

1,110 阅读1分钟

背景

软件:vscode

在入门ts过程中,发现以下流程

  1. 编写文件 helloWorld.ts
  2. 执行tsc helloWorld.ts得到 helloWorld.js
  3. html引入helloWorld文件 或通过 node helloWorld.js 得到输出结果

操作麻烦!!!

更方便的方法

  1. npm install typescript ts-node @types/node@* -g
  2. vscode 安装 Code Runner 插件
  3. 重启vscode

image.png

点击三角符号运行 go!go!go!