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

1.创建 tsconfig.json 文件

1
2
3
4
5
6
7
8
9
10
11
// 全局安装 typescript
npm install -g typescript
 
// 更新 typescript
npm update -g typescript
 
// 查看版本
tsc -v
 
// 初始化
tsc --init

2.tsconfig.json

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
{
  "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.监听变化

1
tsc -w

.

posted @   每天都要进步一点点  阅读(482)  评论(0编辑  收藏  举报
点击右上角即可分享
微信分享提示