目录中存在 tsconfig.json 文件表明该目录是 TypeScript 项目的根目录。 tsconfig.json 文件指定了编译项目所需的根文件和编译器选项。
JavaScript 项目可以改用 jsconfig.json 文件,它的作用几乎相同,但默认情况下启用了一些与 JavaScript 相关的编译器标志。
根据您打算在其中运行代码的 JavaScript 运行时环境,您可以在 github.com/tsconfig/bases 上使用基本配置。 这些是您的项目从中扩展的 tsconfig.json 文件,通过处理运行时支持来简化您的 tsconfig.json。
例如,如果您正在编写一个使用 Node.js 版本 12 及更高版本的项目,那么您可以使用 npm 模块 @tsconfig/node12:
{
"extends": "@tsconfig/node12/tsconfig.json",
"compilerOptions": {
"preserveConstEnums": true
},
"include": ["src/**/*"],
"exclude": ["node_modules", "**/*.spec.ts"]
}
详细参数说明参考这个链接



Specifies an array of filenames or patterns to include in the program. These filenames are resolved relative to the directory containing the tsconfig.json file.
一个例子:
{
"include": ["src/**/*", "tests/**/*"]
}
结果:scripts 文件夹里的 ts 文件没有被包含进去。

更多Jerry的原创文章,尽在:"汪子熙":

网友评论