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]: react-rotuer-dom 6.2.1 (and 6.3.0) depend on react 18 types causing issue with react 17 #8807

Closed
lucas-paulger-sonarsource opened this issue Apr 21, 2022 · 4 comments
Labels

Comments

@lucas-paulger-sonarsource
Copy link

What version of React Router are you using?

react-router-dom 6.2.1

Steps to Reproduce

install these versions

  "react": "17.0.2",
  "react-dom": "17.0.2",
  "react-router-dom": "6.2.1",
  "@types/react": "17.0.2",
  "@types/react-dom": "17.0.2",

and then run a type check
tsc --noEmit

Expected Behavior

no typing errors

Actual Behavior

$ tsc --noEmit
node_modules/react-router-dom/index.d.ts:77:20 - error TS2694: Namespace 'React' has no exported member 'HTMLAttributeAnchorTarget'.

77     target?: React.HTMLAttributeAnchorTarget;
                      ~~~~~~~~~~~~~~~~~~~~~~~~~


Found 1 error.

Reviewing the types of react 17.0.2 and react 18.0.0, I see that HTMLAttributeAnchorTarget only exists in react 18

https://www.jsdocs.io/package/@types/react/v/17.0.2
https://www.jsdocs.io/package/@types/react/v/18.0.0

@simonsmith
Copy link

simonsmith commented Apr 25, 2022

Is there a way to workaround this? Encountering the issue via Storybook

Related: storybookjs/storybook#16925

@gregaubert
Copy link

gregaubert commented Apr 27, 2022

The bug is actually in v17.0.2 of @types/react where this type is missing, while it's present in v16, v18, or the more recent typing version for React 17: v17.0.44
If you make sure to use "@types/react": "17.0.44" it should work fine.

@simonsmith
Copy link

@gregaubert Yep, that worked for me also. Thanks 👍🏻

@timdorr
Copy link
Member

timdorr commented May 4, 2022

Looks like this is fixed upstream.

@timdorr timdorr closed this as completed May 4, 2022
brophdawg11 pushed a commit that referenced this issue Mar 27, 2024
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants