Definitelytyped: New React Types conflict with React-Router-Dom Types

Created on 9 Aug 2017  路  8Comments  路  Source: DefinitelyTyped/DefinitelyTyped

  • [x] I tried using the @types/xxxx package and had problems.
  • [x] I tried using the latest stable version of tsc. https://www.npmjs.com/package/typescript
  • [x] I have a question that is inappropriate for StackOverflow. (Please ask any appropriate questions there).
  • [x] [Mention](https://github.com/blog/821-mention-somebody-they-re-notified) the authors (see Definitions by: in index.d.ts) so they can respond.

    • Authors: @....

Hello,

I just upgraded my @types/react from ^16.0.1 to ^16.0.2 and now I'm seeing this typing conflict with @types/react-router-dom version ^4.0.7. I am using CRA with the latest react-scripts-ts which I believe uses tsc version 2.4.2

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

@richseviora @onigoetz @DovydasNavickas @tkrotoff @morcerf @ericanderson @digiguru @pzavolinsky @bbenezech @tdreyno @tdreyno @johnnyreilly

@tkrotoff @huy-nguyen

Most helpful comment

My situation seems to be a yarn issue. I was able to work around it by doing rm yarn.lock && yarn, after which I had the latest @types/react and everything compiled fine. So it seems to have had trouble in doing an upgrade from my old yarn.lock.

All 8 comments

The problem you're encountering may not be caused by react-router-dom's type definition but rather by yarn (https://github.com/yarnpkg/yarn/issues/1334#issuecomment-319522102) or the recent release of a new version of @types/react (https://github.com/DefinitelyTyped/DefinitelyTyped/issues/18708) or because of a major refactoring that's recently been done for @types/react (https://github.com/DefinitelyTyped/DefinitelyTyped/pull/17921).

Thanks for the links. Yes, I am using yarn and also removed the node_modules folder and did a clean install. Feel free to close but figured it might be useful for one of the devs doing the refactor.

I'm running into this too and would appreciate keeping the issue open unless we know for sure it's another package (or yarn) that's to blame.

Actually, looks like maybe this is a duplicate of #18708?

@pelotom looks like it, in some way. However in #18708 they're using npm, whereas here it's yarn.

My situation seems to be a yarn issue. I was able to work around it by doing rm yarn.lock && yarn, after which I had the latest @types/react and everything compiled fine. So it seems to have had trouble in doing an upgrade from my old yarn.lock.

I ran into this issue as well and am also using Yarn. I found this Stack Overflow answer and confirmed that my node_modules had the problem of the nested React definition being the old version. I had to delete my yarn.lock and re-install from scratch.

See also yarnpkg/yarn#4705.

However according to yarnpkg/yarn#3951 / yarnpkg/yarn#4136 this is caused by using a wildcard dependency when really a peerDependency should have been used.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ArtemZag picture ArtemZag  路  3Comments

demisx picture demisx  路  3Comments

jgoz picture jgoz  路  3Comments

csharpner picture csharpner  路  3Comments

fasatrix picture fasatrix  路  3Comments