在 node_modules/@types/react-dom/...处出错.随后的变量声明必须具有相同的类型.变量'a' [英] Error at node_modules/@types/react-dom/.... Subsequent variable declarations must have the same type. Variable 'a'

查看:86
本文介绍了在 node_modules/@types/react-dom/...处出错.随后的变量声明必须具有相同的类型.变量'a'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经安装了@types/react-dom 以及 typescript 和 @types/react 和 @types/meteor 但是当我尝试从命令行运行类型检查器时,我收到以下错误

I have installed @types/react-dom along with typescript and @types/react and @types/meteor but when I try to run the typechecker from command line I get the below error

您可以在此处重现错误并查看我的所有配置:https://github.com/Falieson/react15-meteor1.5

You can reproduce the error and see all my configuration here: https://github.com/Falieson/react15-meteor1.5

感谢您的帮助!

$ meteor npm run type:client

> react-meteor-example@0.1.0 type:client /Users/sjcfmett/Private/ReactMeteorExample
> tslint -p ./tsconfig.json --type-check './client/**/*.{ts,tsx}'

Error at node_modules/@types/react-dom/node_modules/@types/react/index.d.ts:3422:13: Subsequent variable declarations must have the same type.  Variable 'a' must be of type 'DetailedHTMLProps<AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>', but here has type 'DetailedHTMLProps<AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>'.
Error at node_modules/@types/react-dom/node_modules/@types/react/index.d.ts:3423:13: Subsequent variable declarations must have the same type.  Variable 'abbr' must be of type 'DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>', but here has type 'DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>'.
Error at node_modules/@types/react-dom/node_modules/@types/react/index.d.ts:3424:13: Subsequent variable declarations must have the same type.  Variable 'address' must be of type 'DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>', but here has type 'DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>'.
Error at node_modules/@types/react-dom/node_modules/@types/react/index.d.ts:3425:13: Subsequent variable declarations must have the same type.  Variable 'area' must be of type 'DetailedHTMLProps<AreaHTMLAttributes<HTMLAreaElement>, HTMLAreaElement>', but here has type 'DetailedHTMLProps<AreaHTMLAttributes<HTMLAreaElement>, HTMLAreaElement>'.
... (shortened)

package.json(供参考)

package.json (for reference)

{
  "name": "react-meteor-example",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "start": "meteor run",
    "lint:client": "tslint --fix -c ./tslint.json -p ./tsconfig.json './client/**/*.{ts,tsx}'",
    "lint:imports": "tslint --fix -c ./tslint.json -p ./tsconfig.json './imports/**/*.{ts,tsx}'",
    "lint:server": "tslint --fix -c ./tslint.json -p ./tsconfig.json './server/**/*.ts'",
    "lint": "npm run lint:client && npm run lint:server && npm run lint:imports",
    "type:imports": "tslint -p ./tsconfig.json --type-check './imports/**/*.{ts,tsx}'",
    "type:client": "tslint -p ./tsconfig.json --type-check './client/**/*.{ts,tsx}'",
    "type:server": "tslint -p ./tsconfig.json --type-check './server/**/*.ts'",
    "type": "npm run type:client && npm run type:server && npm run type:imports",
    "precommit": "npm run lint && npm run type"
  },
  "dependencies": {
    "babel-runtime": "^6.20.0",
    "meteor-node-stubs": "~0.2.4",
    "react": "^15.6.1",
    "react-dom": "^15.6.1"
  },
  "devDependencies": {
    "@types/meteor": "^1.4.2",
    "@types/react": "^15.6.0",
    "@types/react-dom": "^15.5.1",
    "babel-preset-react": "^6.24.1",
    "babel-preset-stage-1": "^6.24.1",
    "husky": "^0.14.3",
    "tslint": "^5.5.0",
    "tslint-react": "^3.1.0",
    "typescript": "^2.4.2"
  }
}

推荐答案

React 16 beta 的类型已作为最新"的 React 类型发布.

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

新版本删除了在 React 16 中删除的 React 部分的定义(如 React.DOM),这是预期的.

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

不幸的是,React 16 测试版的这些类型的发布是针对 npm 中的 @latest(默认)标签而不是 @next(就像 React 所做的那样).

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).

我有一个未解决的问题 (#18708),这里有绝对类型:https://github.com/DefinitelyTyped/DefinitelyTyped/issues/18708

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

您可以尝试专门针对特定版本(npm install --save @types/react@15.6.0)但是@types/react 的@types/react-dom 中的依赖项已设置到*",这似乎导致@types/react@latest 仍然被下载,导致你的node_modules 目录的不同地方有多个版本.

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.

我们不得不做一些手动工作来解决这个问题.希望维护@types/react 的人能尽快解决这个问题.

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

这篇关于在 node_modules/@types/react-dom/...处出错.随后的变量声明必须具有相同的类型.变量'a'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆