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 |
.
【推荐】还在用 ECharts 开发大屏?试试这款永久免费的开源 BI 工具!
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步