Cannot use AdminJS + Typescript + (@types/)React v17
See original GitHub issueAdminJS relies on react v16. If the rest of your app uses React v17, Typescipt gets very mad.
../node_modules/@types/react/index.d.ts:3094:14 - error TS2300: Duplicate identifier 'LibraryManagedAttributes'.
3094 type LibraryManagedAttributes<C, P> = C extends React.MemoExoticComponent<infer T> | React.LazyExoticComponent<infer T>
~~~~~~~~~~~~~~~~~~~~~~~~
../node_modules/adminjs/node_modules/@types/react/index.d.ts:3091:14
3091 type LibraryManagedAttributes<C, P> = C extends React.MemoExoticComponent<infer T> | React.LazyExoticComponent<infer T>
~~~~~~~~~~~~~~~~~~~~~~~~
'LibraryManagedAttributes' was also declared here.
../node_modules/@types/react/index.d.ts:3105:13 - error TS2717: Subsequent property declarations must have the same type. Property 'a' must be of type 'DetailedHTMLProps<AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>', but here has type 'DetailedHTMLProps<AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>'.
3105 a: React.DetailedHTMLProps<React.AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>;
~
../node_modules/adminjs/node_modules/@types/react/index.d.ts:3104:13
3104 a: React.DetailedHTMLProps<React.AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>;
~
'a' was also declared here.
This comes from different versions of @types/react
being installed:
$ cat node_modules/adminjs/node_modules/@types/react/package.json | grep version
"version": "16.14.17",
$ cat node_modules/@types/react/package.json | grep version
"version": "17.0.30",
You can see the miss-matched versions of react with npm ls react
and that react-redux is the culprit:
βββ¬ @testing-library/react@12.1.1
β βββ react@17.0.2 deduped
βββ¬ adminjs@5.2.2
β βββ¬ @adminjs/design-system@2.0.2
β β βββ¬ @carbon/icons-react@10.41.0
β β β βββ react@17.0.2 deduped
β β βββ¬ react-datepicker@3.8.0
β β β βββ¬ react-onclickoutside@6.12.0
β β β β βββ react@17.0.2 deduped
β β β βββ¬ react-popper@1.3.11
β β β β βββ¬ @hypnosphi/create-react-context@0.3.1
β β β β β βββ react@17.0.2 deduped
β β β β βββ react@17.0.2 deduped
β β β βββ react@17.0.2 deduped
β β βββ react@16.13.1 deduped
β βββ¬ react-beautiful-dnd@13.1.0
β β βββ¬ react-redux@7.2.5
β β β βββ react@17.0.2 deduped
β β βββ react@17.0.2 deduped
β β βββ¬ use-memo-one@1.1.2
β β βββ react@17.0.2 deduped
β βββ¬ react-dom@16.13.1
β β βββ react@16.13.1 deduped
β βββ¬ react-i18next@11.12.0
β β βββ react@17.0.2 deduped
β βββ¬ react-redux@7.2.0
β β βββ react@16.13.1 deduped. // <---
β βββ¬ react-router-dom@5.2.0
Installed libraries and their versions
"adminjs": "5.2.2",
"@adminjs/passwords": "2.0.0",
"@adminjs/sequelize": "2.0.0",
"react": "17.0.2",
"@types/react": "17.0.30",
Desktop (please complete the following information if relevant):
- OSX
- node version - v15.14.0
- npm version - 7.20.1
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:7 (1 by maintainers)
Top Results From Across the Web
@types/react - npm
Start using @types/react in your project by running `npm i ... TypeScript icon, indicating that this package has built-in type declarations.
Read more >Next.js is not recognizing '@types/react' - Stack Overflow
js app with npm run dev I get an error message saying that I don't have the required packages to run Next with...
Read more >SVG Typescript error - Developers Community by KeenThemes
'SVG' cannot be used as a JSX component. Its instance type 'InlineSVG' is not a valid JSX element. The types returned by 'render()'...
Read more >Node js admin panel with mysql github
I hope this really help others who wish to use Ms SQL while using node. ... No need to register - simply download...
Read more >Module not found: Can't resolve 'react-dom' error | bobbyhadz
with NPM npm install react-dom react # ποΈ ONLY If you use TypeScript npm install --save-dev @types/react-dom @types/react ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I have the same problem. In my project, the only module that is using React is AdminJS. Iβve tried to see why there were 2 different versions of React in my project and it seems that, if I understand correctly, admin js is bringing them:
Is there a fix or a way to work around this issue?
cc @krishnaglick