Node+TS+Koa+vue 商城全栈(四) 配置ts开发环境

1.创建 tsconfig.json 文件
// 全局安装 typescriptnpm install -g typescript
// 更新 typescript
npm update -g typescript
// 查看版本
tsc -v
// 初始化
tsc --init
2.tsconfig.json
{  "compilerOptions": { /* 编译选项 */
    "module": "commonjs", /* 模板 */
    "target": "es2017", /* 生成的目标代码 */
    "outDir": "./dist", /* 生成目录 */
    "noImplicitAny": true, /* 如果有any类型时报错 */
    "removeComments": true, /* 移除注释 */
    "sourceMap": true, /* 是否保留.map文件 */
    "experimentalDecorators": true, /* 是否支持装饰器 */
    "emitDecoratorMetadata": true, /* 是否支持元素 */
    "typeRoots": [ /* 类型声明文件的地址 */
      "node_modules/@types", /* 默认 */
      "@miaov-types" /* 自定义 */
    ]
  },
  "compileOnSave": true, /* 保存时自动编译 */
  "includes": [ /* 包含文件 */
    "app/**/*"
  ],
  "exclude": [ /* 排除文件 */
    "node_modules",
    "dist",
    "models",
    "migrations",
    "seeders",
    "test"
  ]
}
3.监听变化
tsc -w
.
以上是 Node+TS+Koa+vue 商城全栈(四) 配置ts开发环境 的全部内容, 来源链接: utcz.com/z/374603.html






