我有一个tsconfig.json
包含显式的文件include
模式为src/**/*
。我也有测试存在于test/
,但这些仅使用执行ts-jest
我从来不想把它们编译成我的dist
文件夹或在捆绑源代码时包含它们。
这工作正常,除了我开始在一些测试文件中收到警告,因为需要标志,例如esModuleInterop
. Since test/
不包含在tsconfig.json
,不仅构建时会忽略测试文件,而且测试文件的标志也不会处于活动状态。
我怎样才能写一个tsconfig.json
归档该文件
- 仅编译以下文件
src/
to dist/
- 仍然尊重文件的标志
test/
and tools/
我设法单独放置一个tsconfig.json
文件在我的test/
文件夹和我的另一个文件夹tools/
文件夹,但我想知道是否可以避免这种情况并且只有一个文件?
据我所知,您无法构建某些文件,而只能从单个 tsconfig 中对其他文件进行类型检查。但是,为了节省 tsconfig 标志的重复,您可以使用“延伸” https://www.typescriptlang.org/tsconfig#extends option:
project/tsconfig.json
:
{
"compilerOptions": {
"esModuleInterop": true
// other options here
},
"include": ["src/**/*"]
}
project/test/tsconfig.json
:
{
"extends": "../tsconfig.json"
// compilerOptions will be inherited
// you may need to set "include" here relative to the "test" directory
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)