Definitelytyped: types/react-dom Same type error does not make sense

Created on 14 Feb 2018  路  7Comments  路  Source: DefinitelyTyped/DefinitelyTyped

Using @types/react-dom, after upgrade to Typescript 2.7 - got the following error, which doesn't makes sense - the types are the same (also, using the latest @types/react-dom and react-dom):

ERROR in [at-loader] ./node_modules/@types/react-dom/node_modules/@types/react/index.d.ts:3782:13 
    TS2717: Subsequent property declarations must have the same type.  Property 'dialog' must be of type 'DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>', but here has type 'DetailedHTMLProps<DialogHTMLAttributes<HTMLDialogElement>, HTMLDialogElement>'.

ERROR in [at-loader] ./node_modules/@types/react-dom/node_modules/@types/react/index.d.ts:3806:13 
    TS2717: Subsequent property declarations must have the same type.  Property 'img' must be of type 'DetailedHTMLProps<ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>', but here has type 'DetailedHTMLProps<ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>'.

  • Authors: @MartynasZilinskas @theruther4d - your help is appriciated.

yarn file:
yarn.lock.tar.gz

Most helpful comment

This seems related to a recent change made in DefinitelyTyped/DefinitelyTyped#23053.

I resolved the issue by removing node_modules/@types/react-dom, then running yarn upgrade @types/react-dom to pull in the current declaration files. Although I'm still unclear why some @types packages create their own node_modules directory, this particular issues appears to be a result of an old @types/react declaration file sticking around that specified TS 2.3, which was changed in PR 23053 to require TS 2.6.

All 7 comments

This seems related to a recent change made in DefinitelyTyped/DefinitelyTyped#23053.

I resolved the issue by removing node_modules/@types/react-dom, then running yarn upgrade @types/react-dom to pull in the current declaration files. Although I'm still unclear why some @types packages create their own node_modules directory, this particular issues appears to be a result of an old @types/react declaration file sticking around that specified TS 2.3, which was changed in PR 23053 to require TS 2.6.

Thanks, @corydeppen.
Similar way, I resolved it by taking a new clean branch, upgrade TS to 2.7 then deleting the node_modules folder and upgrading all the @types.

I was also, very surprised and confused to find "sub" @@types folders, with packages I have no control of.

Your explanation helps. Thanks.

I followed all the advice and I'm still getting the same error.

If you're using Yarn, try deleting yarn.lock and run yarn clean cache too. That's what worked for me.

@corydeppen thanks so much, I've had to follow your instructions there about 5 times in a row now. It seems pretty much everytime I update the react or react-dom types I need to perform it. Feels like it could be a bug in yarn.

I followed all the advice and I'm still getting the same error.

well done!

Was this page helpful?
0 / 5 - 0 ratings