在TypeScript设置中,我有一个库(mylibrary
)和该库的使用者(consumer
)。两者都与react
相关,因此也与@types/react
相关。 mylibrary
直接依赖于react
。 consumer
通过react
依赖关系与react-router
保持联系。
mylibrary
的最低要求是@types/react
^16.8.0
,而react-router
的{{1}}的最低要求是@types/react
。
*
依赖项已解析为@types/react
。 (在^16.8.0
中执行yarn
时)
consumer
依赖关系已解析为@types/react
。
如何在16.4.14
中为@types/react
指定最低要求的^16.8.0
版本,以便在mylibrary
中解析此@types/react
版本?
package.json consumer
consumer
package.json "dependencies": {
"react-router": "4.3.1",
"@types/react-router": "4.4.4", (has a dependency on @types/react: *)
"mylibrary": "5.0.8" (has a dependency on @types/react: ^16.8.0)
}
mylibrary
$了解为什么@ types / react
"dependencies": {
"react": "16.8.3",
"@types/react": "^16.8.0"
}
yarn.lock
=> Found "@types/react@16.4.14"
info Reasons this module exists
- "@types#react-router" depends on it
- Hoisted from "@types#react-router#@types#react"