基本开发环境

node npm vscode cmd chrome

安装

npm install -g typescript

编译

tsc *.ts

tsconfig.json配置

  1. {
  2. "compilerOptions": { //编译选项
  3. "target": "es2015",
  4. "module": "commonjs",
  5. "outDir": "lib"
  6. },
  7. "include": [ //源码位置
  8. "src/**/*"
  9. ]
  10. }

通过package.js编译

  1. "scripts": {
  2. "start": "tsc --watch", //实时监听文件变化,自动编译
  3. "build": "tsc", //编译一次
  4. "test": "echo \"Error: no test specified\" && exit 1"
  5. },