typescript - 不兼容的相同类型
问题描述
有几次,我遇到了不寻常的类型错误,形式如下:
Type 'SomeType<SomeGeneric>' is not assignable to type 'SomeType<SomeGeneric>'.
奇怪的是,据我所知,这两种类型似乎是相同的。它们都来自同一个模块。只是模块存在于两个地方。它存在于 的顶层node_modules
,也作为另一个模块的依赖存在。TypeScript 认为这两种类型是不兼容的,尽管在检查这两种类型的来源后,它们似乎是相同的。两个模块的版本相同。
这个问题的另一个奇怪的方面是,虽然类型错误出现在独立的 TypeScript 编译器中,但它没有出现在Atom using ide-typescript
.
有什么理由会出现这种情况吗?
这是tsconfig.json
:
{
"composite": true,
"declaration": true,
"sourceMap": true,
"target": "es2015",
"module": "ES6",
"moduleResolution": "node",
"baseUrl": "./",
"outDir": "./build/",
"lib":
[
"es2015",
"es2017"
],
"removeComments": true,
"downlevelIteration": true,
"alwaysStrict": true,
"allowSyntheticDefaultImports": true,
"strictNullChecks": true,
"resolveJsonModule": true,
"paths":
{
"common/*": ["../Common/*"]
},
"watch": true
}
任何帮助将非常感激!
解决方案
推荐阅读
- javascript - 显式传递道具以访问它以供 React 使用?
- python - 在 Python 中计算推文中的脏话
- python - 如何使用 Azure Blob 触发器写入 Azure 数据库
- opencv - 为什么 Canny 边缘检测后不能画线?
- javascript - 删除执行 imacros 脚本时打开的第二页
- r - 将随机样本与替换与 R 中原始数据帧中的值相结合
- node.js - NestJS .env 文件未构建
- python - (已解决)是否可以在 python 上检测到客户端与服务器套接字的意外断开连接?
- paypal - Paypal 自定义付款金额
- laravel - Laravel Mqtt 的订阅没有结束