如何在TS库中指定最小类型依赖项版本

时间:2019-02-27 10:42:44

标签: reactjs typescript npm yarnpkg package.json

概述

在TypeScript设置中,我有一个库(mylibrary)和该库的使用者(consumer)。两者都与react相关,因此也与@types/react相关。 mylibrary直接依赖于reactconsumer通过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"

0 个答案:

没有答案