Error at node_modules/@types/react-dom/… Subsequent variable declarations must have the same type. Variable 'a'

巧了我就是萌 提交于 2019-12-05 06:53:35

The types for React 16 beta have been published as the 'latest' React types.

The new version removes the definitions for the parts of React that have been removed in React 16 (like React.DOM), which is expected.

Unfortunately, the publishing of these types for the React 16 beta were done to the @latest (default) tag in npm instead of @next (as React did).

I have an open issue (#18708) with DefinitelyTyped here: https://github.com/DefinitelyTyped/DefinitelyTyped/issues/18708

You can try specifically targeting a particular release (npm install --save @types/react@15.6.0) but the dependencies in @types/react-dom for @types/react is set to "*", which seems to cause @types/react@latest to still be downloaded, causing you to have multiple versions in various places of your node_modules directory.

We are having to do some manual work to sort this out. Hopefully the folks maintaining @types/react will fix this soon.

I am using yarn, and fixed this by running rm -rf node_modules && rm yarn.lock && yarn install

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!