- 清空 tsconfig.ts 文件
如果没有任何配置,编译器就会按照默认配置编译当前目录下所有ts文件
与文件相关的选项
- 在 src 目录下新建 afile.ts 文件
// src/afile.ts let ss: string = 'a';
tsc
执行编译
//tsconfig.json
{
"files": [ //表示编译器需要编译的单个文件列表
"src/afile.ts"
],
"include": [//编译器需要编译的文件或者是目录,支持通配符
"src/*"
],
"exclude": [//编译器需要排除的文件夹
"src/lib"
]
}
- 配置文件支持继承
-
根目录下新建 tsconfig.base.json
//tsconfig.base.json { "files": [ //表示编译器需要编译的单个文件列表 "src/afile.ts" ], "include": [//编译器需要编译的文件或者是目录,支持通配符 "src/*" ], "exclude": [//编译器需要排除的文件夹 "src/lib" ] }
//tsconofig.json { "extends": "./tsconfig.base", "exclude": [],//可以覆盖被继承文件 "compileOnSave": true, //保存文件时自动编译(vscode不支持) }
-
与编译相关的选项