Skip to content
This repository has been archived by the owner on Jun 11, 2020. It is now read-only.

Add inferred dependencies to peerDependencies? #366

Closed
sthuck opened this issue Jul 30, 2017 · 3 comments
Closed

Add inferred dependencies to peerDependencies? #366

sthuck opened this issue Jul 30, 2017 · 3 comments

Comments

@sthuck
Copy link

sthuck commented Jul 30, 2017

Hi guys,

I'll start with the example scenario -
my package.json has these dependencies:

    "@types/angular": "~1.5.0",
    "@types/angular-mocks": "^1.5.0"

and @types/angular-mocks package.json looks like this, as it's dependencies are automatically inferred:

 "dependencies": {
        "@types/angular": "*"
    },

since @types/angular": "*" gets resolved to @types/angular version 1.6.23 (in Yarn 0.27.5), I end up with the types for angular 1.6. Obviously this is just an example and will happen with any type definitions that has breaking changes compared to previous type definitions.

You can see the discussion with yarn guys yarnpkg/yarn#3951, where they explain why '*' is being resolved to latest version and not simply to "any version". They suggest using peerDependencies instead, which does seem (to me at least) like the correct thing to do.

I do understand this has potential to pop up a 'missing peer dependency' error for lots and lots of people.
But if I understand this bug correctly, as time will pass and new type definitions will break previous versions, more yarn users will experience this issue. So I guess this is for your consideration...

@cwmoo740
Copy link

cwmoo740 commented Jul 31, 2017

Ditto for react.

"@types/react": "^15.0.39",
"@types/react-dom": "^15.5.0"

where "@types/react-dom" has:

"@types/react": "*"

This results in the structure:

node_modules
-@types
--react (15.0.39)
--react-dom
---node_modules
----@types
-----react (15.0.33)

@sthuck and the yarn people seemed to indicate that yarn would pick "latest" for a dependency of *, but that doesn't seem to be the case here.

@gilamran
Copy link

gilamran commented Aug 7, 2017

Installing
@types/react@^15.6.1
@types/react-dom@^15.5.2 (Depends on @types/react@*)

Will install nested node_modules/@types/react-dom/node_modules/@types/react (version 16, the latest).

This will cause many errors like this one:

node_modules/@types/react-dom/node_modules/@types/react/index.d.ts(3422,13): error TS2403: Subsequent variable declarations must have the same type.  Variable 'a' must be of type 'DetailedHTMLProps<AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>', but here has type 'DetailedHTMLProps<AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>'.

@cwmoo740
Copy link

cwmoo740 commented Aug 7, 2017

There's a few lines in yarn.lock that look something like:

"@types/react@*":
  resolved: some_url

"@types/react@15.6.0":
  resolved: some_url

manually editing these to combine react@* and react@15.6.0 fixes the problem:

"@types/react@*", "@types/react@^15.6.0":
  resolved: the url for @types/react@15.6.0

this will cause all of the dependencies on @types/react@* to resolve the way you expect.

glentakahashi added a commit to glentakahashi/types-publisher that referenced this issue Aug 15, 2017
Add all of the typesDependencies to be added as peerDependencies instead of dependencies to fix transitive dependency issues such as in microsoft#366
@sthuck sthuck closed this as completed Sep 11, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants