Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: @types/axios is not listed as a peerDependency, even though index.d.ts references it #168

Open
mprast opened this issue May 8, 2021 · 3 comments

Comments

@mprast
Copy link

mprast commented May 8, 2021

Trying to use this package with yarn v2 & tsc and it's breaking because of this. Any objections to adding it in? Happy to submit a PR if needed.

@dls314
Copy link

dls314 commented Sep 2, 2022

I'm curious to learn what you've seen as patterns in this scenario.

@types/axios would be a sad thing to carry as a dependency as it should contain only type information and no impact on runtime code. But there's no such declaration as peerDevDependency -- which is kind of what is necessary if I understand it right.

I've tried using import type to be more explicit in some places, but I'm not sure this would help (not using yarn, so no equivalent experience)

@elado
Copy link

elado commented Aug 1, 2023

Axios includes types, so having it as a peer dep is required in a monorepo where there's a risk of multiple axios versions, some hoisted, some not (by yarn). When a package relies on axios and axios-retry, axios-retry may be hoisted, and the type it'll try to load would be from a hoisted axios, which might cause a conflict.

Example:

node_modules/
  axios-retry/
  axios v0.18.0

packages/
  foo/
    node_modules/
      axios v0.19.0

importing axios-retry inside foo would use 0.18.0 types but the axios passed in is 0.19.0.

Solved it by adding this to .yarnrc.yml:

packageExtensions:
  axios-retry@^3.3.1:
    peerDependencies:
      axios: "*"

which causes a duplicated axios-retry but now it imports the right version

node_modules/
  axios-retry/
  axios v0.18.0

packages/
  foo/
    node_modules/
      axios v0.19.0
      axios-retry/

@jfirebaugh
Copy link

Now that @types/axios is a stub package, axios should be a peer dependency.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants