typescript - 为什么 tsc 忽略 tsconfig.json 中的 include 和 exclude?
问题描述
我有tsconfig.json
:
{
"compilerOptions": {
"target": "ES6",
"lib": [
"DOM",
"ES6"
]
},
"include": [
"src/server/**/*"
],
"exclude": [
"node_modules",
"dist",
"public"
]
}
当我运行tsc --project tsconfig.json
它时,它完全忽略了include
和配置并且编译exclude
失败。node_modules
它成功的唯一方法是tsc src/server/**/*.ts
,但后来它没有使用配置。
我验证了编译器会处理配置,因为当我添加"watch": true
到时"compilerOptions"
,它会等待更改。
我查看了文档,但没有得到它。看起来我把它放在了 json 文件中的正确位置。
有谁知道,如何解决它?
macOS Big Sur 上的编译器版本:
% tsc -v
Version 4.0.5
解决方案
正如问题下方的评论中所写,我必须添加"skipLibCheck": true
,所以最终的 json 看起来像:
{
"compilerOptions": {
"target": "ES6",
"lib": [
"DOM",
"ES6"
],
"skipLibCheck": true
},
"include": [
"src/server/**/*"
],
"exclude": [
"node_modules",
"dist",
"public"
]
}
然后编译成功:
% tsc -p tsconfig.json
% echo $?
0
推荐阅读
- reactjs - 如何为多个范围创建查询?
- amazon-s3 - 如何在 boto3 S3 客户端配置中指定 FIPS 端点 url?
- java - 在背包问题中无法输出姓名
- node.js - 对 mongodb 的并发简单请求非常慢
- azure-blob-storage - 使用 Blazor 服务器端,是否可以在大文件上从控制器到客户端获取文件进度上传状态?
- python - 如何将带有 IN 子句的 SQL 参数用于带有 pyodbc 的可变数量的值?
- sql - 试图用 SQL 找出 Liquibase 回滚
- mysql - 连接到 mysql 后保持 ssh 会话处于活动状态
- msbuild - 将 Azure Pipelines 与多目标项目一起使用时出现错误 NETSDK1061
- cmd - 如何将动态创建的文件夹移动到另一个文件夹中?