安装react-redux后编译错误

时间:2017-01-26 22:36:28

标签: reactjs typescript redux react-redux

我有一个React / typescript项目工作正常。

我想使用redux,所以我尝试: npm install --save redux react-redux @ types / redux @ types / react-redux

如果不编写一行代码,我执行webpack并收到这些错误:

    ERROR in /home/minas/Projects/humorista-website/node_modules/@types/react-dom/index.d.ts
(18,31): error TS2315: Type 'DOMAttributes' is not generic.

ERROR in /home/minas/Projects/humorista-website/node_modules/@types/react-dom/index.d.ts
(43,60): error TS2315: Type 'DOMAttributes' is not generic.

ERROR in /home/minas/Projects/humorista-website/node_modules/@types/react/index.d.ts
(2634,13): error TS2403: Subsequent variable declarations must have the same type.  Variable 'a' must be of type 'HTMLProps<HTMLAnchorElement>', but here has type 'HTMLProps<HTMLAnchorElement>'.

ERROR in /home/minas/Projects/humorista-website/node_modules/@types/react/index.d.ts
(2635,13): error TS2403: Subsequent variable declarations must have the same type.  Variable 'abbr' must be of type 'HTMLProps<HTMLElement>', but here has type 'HTMLProps<HTMLElement>'.

ERROR in /home/minas/Projects/humorista-website/node_modules/@types/react/index.d.ts
(2636,13): error TS2403: Subsequent variable declarations must have the same type.  Variable 'address' must be of type 'HTMLProps<HTMLElement>', but here has type 'HTMLProps<HTMLElement>'.

ERROR in /home/minas/Projects/humorista-website/node_modules/@types/react/index.d.ts
(2637,13): error TS2403: Subsequent variable declarations must have the same type.  Variable 'area' must be of type 'HTMLProps<HTMLAreaElement>', but here has type 'HTMLProps<HTMLAreaElement>'.

ERROR in /home/minas/Projects/humorista-website/node_modules/@types/react/index.d.ts
(2638,13): error TS2403: Subsequent variable declarations must have the same type.  Variable 'article' must be of type 'HTMLProps<HTMLElement>', but here has type 'HTMLProps<HTMLElement>'.

ERROR in /home/minas/Projects/humorista-website/node_modules/@types/react/index.d.ts
(2639,13): error TS2403: Subsequent variable declarations must have the same type.  Variable 'aside' must be of type 'HTMLProps<HTMLElement>', but here has type 'HTMLProps<HTMLElement>'.

ERROR in /home/minas/Projects/humorista-website/node_modules/@types/react/index.d.ts
(2640,13): error TS2403: Subsequent variable declarations must have the same type.  Variable 'audio' must be of type 'HTMLProps<HTMLAudioElement>', but here has type 'HTMLProps<HTMLAudioElement>'.

ERROR in /home/minas/Projects/humorista-website/node_modules/@types/react/index.d.ts
(2641,13): error TS2403: Subsequent variable declarations must have the same type.  Variable 'b' must be of type 'HTMLProps<HTMLElement>', but here has type 'HTMLProps<HTMLElement>'.

ERROR in /home/minas/Projects/humorista-website/node_modules/@types/react/index.d.ts
(2642,13): error TS2403: Subsequent variable declarations must have the same type.  Variable 'base' must be of type 'HTMLProps<HTMLBaseElement>', but here has type 'HTMLProps<HTMLBaseElement>'.

ERROR in /home/minas/Projects/humorista-website/node_modules/@types/react/index.d.ts
(2643,13): error TS2403: Subsequent variable declarations must have the same type.  Variable 'bdi' must be of type 'HTMLProps<HTMLElement>', but here has type 'HTMLProps<HTMLElement>'.

ERROR in /home/minas/Projects/humorista-website/node_modules/@types/react/index.d.ts
(2644,13): error TS2403: Subsequent variable declarations must have the same type.  Variable 'bdo' must be of type 'HTMLProps<HTMLElement>', but here has type 'HTMLProps<HTMLElement>'.

ERROR in /home/minas/Projects/humorista-website/node_modules/@types/react/index.d.ts
(2645,13): error TS2403: Subsequent variable declarations must have the same type.  Variable 'big' must be of type 'HTMLProps<HTMLElement>', but here has type 'HTMLProps<HTMLElement>'.

ERROR in /home/minas/Projects/humorista-website/node_modules/@types/react/index.d.ts
(2646,13): error TS2403: Subsequent variable declarations must have the same type.  Variable 'blockquote' must be of type 'HTMLProps<HTMLElement>', but here has type 'HTMLProps<HTMLElement>'.

ERROR in /home/minas/Projects/humorista-website/node_modules/@types/react/index.d.ts
(2647,13): error TS2403: Subsequent variable declarations must have the same type.  Variable 'body' must be of type 'HTMLProps<HTMLBodyElement>', but here has type 'HTMLProps<HTMLBodyElement>'.

ERROR in /home/minas/Projects/humorista-website/node_modules/@types/react/index.d.ts
(2648,13): error TS2403: Subsequent variable declarations must have the same type.  Variable 'br' must be of type 'HTMLProps<HTMLBRElement>', but here has type 'HTMLProps<HTMLBRElement>'.

ERROR in /home/minas/Projects/humorista-website/node_modules/@types/react/index.d.ts
(2649,13): error TS2403: Subsequent variable declarations must have the same type.  Variable 'button' must be of type 'HTMLProps<HTMLButtonElement>', but here has type 'HTMLProps<HTMLButtonElement>'.

ERROR in /home/minas/Projects/humorista-website/node_modules/@types/react/index.d.ts
(2650,13): error TS2403: Subsequent variable declarations must have the same type.  Variable 'canvas' must be of type 'HTMLProps<HTMLCanvasElement>', but here has type 'HTMLProps<HTMLCanvasElement>'.

ERROR in /home/minas/Projects/humorista-website/node_modules/@types/react/index.d.ts
(2651,13): error TS2403: Subsequent variable declarations must have the same type.  Variable 'caption' must be of type 'HTMLProps<HTMLElement>', but here has type 'HTMLProps<HTMLElement>'.

ERROR in /home/minas/Projects/humorista-website/node_modules/@types/react/index.d.ts
(2652,13): error TS2403: Subsequent variable declarations must have the same type.  Variable 'cite' must be of type 'HTMLProps<HTMLElement>', but here has type 'HTMLProps<HTMLElement>'.

ERROR in /home/minas/Projects/humorista-website/node_modules/@types/react/index.d.ts
(2653,13): error TS2403: Subsequent variable declarations must have the same type.  Variable 'code' must be of type 'HTMLProps<HTMLElement>', but here has type 'HTMLProps<HTMLElement>'.

ERROR in /home/minas/Projects/humorista-website/node_modules/@types/react/index.d.ts
(2654,13): error TS2403: Subsequent variable declarations must have the same type.  Variable 'col' must be of type 'HTMLProps<HTMLTableColElement>', but here has type 'HTMLProps<HTMLTableColElement>'.

ERROR in /home/minas/Projects/humorista-website/node_modules/@types/react/index.d.ts
(2655,13): error TS2403: Subsequent variable declarations must have the same type.  Variable 'colgroup' must be of type 'HTMLProps<HTMLTableColElement>', but here has type 'HTMLProps<HTMLTableColElement>'.

ERROR in /home/minas/Projects/humorista-website/node_modules/@types/react/index.d.ts
(2656,13): error TS2403: Subsequent variable declarations must have the same type.  Variable 'data' must be of type 'HTMLProps<HTMLElement>', but here has type 'HTMLProps<HTMLElement>'.

ERROR in /home/minas/Projects/humorista-website/node_modules/@types/react/index.d.ts
(2657,13): error TS2403: Subsequent variable declarations must have the same type.  Variable 'datalist' must be of type 'HTMLProps<HTMLDataListElement>', but here has type 'HTMLProps<HTMLDataListElement>'.

ERROR in /home/minas/Projects/humorista-website/node_modules/@types/react/index.d.ts
(2658,13): error TS2403: Subsequent variable declarations must have the same type.  Variable 'dd' must be of type 'HTMLProps<HTMLElement>', but here has type 'HTMLProps<HTMLElement>'.

ERROR in /home/minas/Projects/humorista-website/node_modules/@types/react/index.d.ts
(2659,13): error TS2403: Subsequent variable declarations must have the same type.  Variable 'del' must be of type 'HTMLProps<HTMLElement>', but here has type 'HTMLProps<HTMLElement>'.

ERROR in /home/minas/Projects/humorista-website/node_modules/@types/react/index.d.ts
(2660,13): error TS2403: Subsequent variable declarations must have the same type.  Variable 'details' must be of type 'HTMLProps<HTMLElement>', but here has type 'HTMLProps<HTMLElement>'.

ERROR in /home/minas/Projects/humorista-website/node_modules/@types/react/index.d.ts
(2661,13): error TS2403: Subsequent variable declarations must have the same type.  Variable 'dfn' must be of type 'HTMLProps<HTMLElement>', but here has type 'HTMLProps<HTMLElement>'.

ERROR in /home/minas/Projects/humorista-website/node_modules/@types/react/index.d.ts
(2662,13): error TS2403: Subsequent variable declarations must have the same type.  Variable 'dialog' must be of type 'HTMLProps<HTMLElement>', but here has type 'HTMLProps<HTMLElement>'.

ERROR in /home/minas/Projects/humorista-website/node_modules/@types/react/index.d.ts
(2663,13): error TS2403: Subsequent variable declarations must have the same type.  Variable 'div' must be of type 'HTMLProps<HTMLDivElement>', but here has type 'HTMLProps<HTMLDivElement>'.

ERROR in /home/minas/Projects/humorista-website/node_modules/@types/react/index.d.ts
(2664,13): error TS2403: Subsequent variable declarations must have the same type.  Variable 'dl' must be of type 'HTMLProps<HTMLDListElement>', but here has type 'HTMLProps<HTMLDListElement>'.

ERROR in /home/minas/Projects/humorista-website/node_modules/@types/react/index.d.ts
(2665,13): error TS2403: Subsequent variable declarations must have the same type.  Variable 'dt' must be of type 'HTMLProps<HTMLElement>', but here has type 'HTMLProps<HTMLElement>'.

ERROR in /home/minas/Projects/humorista-website/node_modules/@types/react/index.d.ts
(2666,13): error TS2403: Subsequent variable declarations must have the same type.  Variable 'em' must be of type 'HTMLProps<HTMLElement>', but here has type 'HTMLProps<HTMLElement>'.

ERROR in /home/minas/Projects/humorista-website/node_modules/@types/react/index.d.ts
(2667,13): error TS2403: Subsequent variable declarations must have the same type.  Variable 'embed' must be of type 'HTMLProps<HTMLEmbedElement>', but here has type 'HTMLProps<HTMLEmbedElement>'.

ERROR in /home/minas/Projects/humorista-website/node_modules/@types/react/index.d.ts
(2668,13): error TS2403: Subsequent variable declarations must have the same type.  Variable 'fieldset' must be of type 'HTMLProps<HTMLFieldSetElement>', but here has type 'HTMLProps<HTMLFieldSetElement>'.

ERROR in /home/minas/Projects/humorista-website/node_modules/@types/react/index.d.ts
(2669,13): error TS2403: Subsequent variable declarations must have the same type.  Variable 'figcaption' must be of type 'HTMLProps<HTMLElement>', but here has type 'HTMLProps<HTMLElement>'.

ERROR in /home/minas/Projects/humorista-website/node_modules/@types/react/index.d.ts
(2670,13): error TS2403: Subsequent variable declarations must have the same type.  Variable 'figure' must be of type 'HTMLProps<HTMLElement>', but here has type 'HTMLProps<HTMLElement>'.

ERROR in /home/minas/Projects/humorista-website/node_modules/@types/react/index.d.ts
(2671,13): error TS2403: Subsequent variable declarations must have the same type.  Variable 'footer' must be of type 'HTMLProps<HTMLElement>', but here has type 'HTMLProps<HTMLElement>'.

ERROR in /home/minas/Projects/humorista-website/node_modules/@types/react/index.d.ts
(2672,13): error TS2403: Subsequent variable declarations must have the same type.  Variable 'form' must be of type 'HTMLProps<HTMLFormElement>', but here has type 'HTMLProps<HTMLFormElement>'.

ERROR in /home/minas/Projects/humorista-website/node_modules/@types/react/index.d.ts
(2673,13): error TS2403: Subsequent variable declarations must have the same type.  Variable 'h1' must be of type 'HTMLProps<HTMLHeadingElement>', but here has type 'HTMLProps<HTMLHeadingElement>'.

ERROR in /home/minas/Projects/humorista-website/node_modules/@types/react/index.d.ts
(2674,13): error TS2403: Subsequent variable declarations must have the same type.  Variable 'h2' must be of type 'HTMLProps<HTMLHeadingElement>', but here has type 'HTMLProps<HTMLHeadingElement>'.

ERROR in /home/minas/Projects/humorista-website/node_modules/@types/react/index.d.ts
(2675,13): error TS2403: Subsequent variable declarations must have the same type.  Variable 'h3' must be of type 'HTMLProps<HTMLHeadingElement>', but here has type 'HTMLProps<HTMLHeadingElement>'.

ERROR in /home/minas/Projects/humorista-website/node_modules/@types/react/index.d.ts
(2676,13): error TS2403: Subsequent variable declarations must have the same type.  Variable 'h4' must be of type 'HTMLProps<HTMLHeadingElement>', but here has type 'HTMLProps<HTMLHeadingElement>'.

ERROR in /home/minas/Projects/humorista-website/node_modules/@types/react/index.d.ts
(2677,13): error TS2403: Subsequent variable declarations must have the same type.  Variable 'h5' must be of type 'HTMLProps<HTMLHeadingElement>', but here has type 'HTMLProps<HTMLHeadingElement>'.

ERROR in /home/minas/Projects/humorista-website/node_modules/@types/react/index.d.ts
(2678,13): error TS2403: Subsequent variable declarations must have the same type.  Variable 'h6' must be of type 'HTMLProps<HTMLHeadingElement>', but here has type 'HTMLProps<HTMLHeadingElement>'.

ERROR in /home/minas/Projects/humorista-website/node_modules/@types/react/index.d.ts
(2679,13): error TS2403: Subsequent variable declarations must have the same type.  Variable 'head' must be of type 'HTMLProps<HTMLHeadElement>', but here has type 'HTMLProps<HTMLHeadElement>'.

ERROR in /home/minas/Projects/humorista-website/node_modules/@types/react/index.d.ts
(2680,13): error TS2403: Subsequent variable declarations must have the same type.  Variable 'header' must be of type 'HTMLProps<HTMLElement>', but here has type 'HTMLProps<HTMLElement>'.

ERROR in /home/minas/Projects/humorista-website/node_modules/@types/react/index.d.ts
(2681,13): error TS2403: Subsequent variable declarations must have the same type.  Variable 'hgroup' must be of type 'HTMLProps<HTMLElement>', but here has type 'HTMLProps<HTMLElement>'.

ERROR in /home/minas/Projects/humorista-website/node_modules/@types/react/index.d.ts
(2682,13): error TS2403: Subsequent variable declarations must have the same type.  Variable 'hr' must be of type 'HTMLProps<HTMLHRElement>', but here has type 'HTMLProps<HTMLHRElement>'.

ERROR in /home/minas/Projects/humorista-website/node_modules/@types/react/index.d.ts
(2683,13): error TS2403: Subsequent variable declarations must have the same type.  Variable 'html' must be of type 'HTMLProps<HTMLHtmlElement>', but here has type 'HTMLProps<HTMLHtmlElement>'.

ERROR in /home/minas/Projects/humorista-website/node_modules/@types/react/index.d.ts
(2684,13): error TS2403: Subsequent variable declarations must have the same type.  Variable 'i' must be of type 'HTMLProps<HTMLElement>', but here has type 'HTMLProps<HTMLElement>'.

ERROR in /home/minas/Projects/humorista-website/node_modules/@types/react/index.d.ts
(2685,13): error TS2403: Subsequent variable declarations must have the same type.  Variable 'iframe' must be of type 'HTMLProps<HTMLIFrameElement>', but here has type 'HTMLProps<HTMLIFrameElement>'.

ERROR in /home/minas/Projects/humorista-website/node_modules/@types/react/index.d.ts
(2686,13): error TS2403: Subsequent variable declarations must have the same type.  Variable 'img' must be of type 'HTMLProps<HTMLImageElement>', but here has type 'HTMLProps<HTMLImageElement>'.

ERROR in /home/minas/Projects/humorista-website/node_modules/@types/react/index.d.ts
(2687,13): error TS2403: Subsequent variable declarations must have the same type.  Variable 'input' must be of type 'HTMLProps<HTMLInputElement>', but here has type 'HTMLProps<HTMLInputElement>'.

ERROR in /home/minas/Projects/humorista-website/node_modules/@types/react/index.d.ts
(2688,13): error TS2403: Subsequent variable declarations must have the same type.  Variable 'ins' must be of type 'HTMLProps<HTMLModElement>', but here has type 'HTMLProps<HTMLModElement>'.

ERROR in /home/minas/Projects/humorista-website/node_modules/@types/react/index.d.ts
(2689,13): error TS2403: Subsequent variable declarations must have the same type.  Variable 'kbd' must be of type 'HTMLProps<HTMLElement>', but here has type 'HTMLProps<HTMLElement>'.

ERROR in /home/minas/Projects/humorista-website/node_modules/@types/react/index.d.ts
(2690,13): error TS2403: Subsequent variable declarations must have the same type.  Variable 'keygen' must be of type 'HTMLProps<HTMLElement>', but here has type 'HTMLProps<HTMLElement>'.

ERROR in /home/minas/Projects/humorista-website/node_modules/@types/react/index.d.ts
(2691,13): error TS2403: Subsequent variable declarations must have the same type.  Variable 'label' must be of type 'HTMLProps<HTMLLabelElement>', but here has type 'HTMLProps<HTMLLabelElement>'.

ERROR in /home/minas/Projects/humorista-website/node_modules/@types/react/index.d.ts
(2692,13): error TS2403: Subsequent variable declarations must have the same type.  Variable 'legend' must be of type 'HTMLProps<HTMLLegendElement>', but here has type 'HTMLProps<HTMLLegendElement>'.

ERROR in /home/minas/Projects/humorista-website/node_modules/@types/react/index.d.ts
(2693,13): error TS2403: Subsequent variable declarations must have the same type.  Variable 'li' must be of type 'HTMLProps<HTMLLIElement>', but here has type 'HTMLProps<HTMLLIElement>'.

ERROR in /home/minas/Projects/humorista-website/node_modules/@types/react/index.d.ts
(2694,13): error TS2403: Subsequent variable declarations must have the same type.  Variable 'link' must be of type 'HTMLProps<HTMLLinkElement>', but here has type 'HTMLProps<HTMLLinkElement>'.

ERROR in /home/minas/Projects/humorista-website/node_modules/@types/react/index.d.ts
(2695,13): error TS2403: Subsequent variable declarations must have the same type.  Variable 'main' must be of type 'HTMLProps<HTMLElement>', but here has type 'HTMLProps<HTMLElement>'.

ERROR in /home/minas/Projects/humorista-website/node_modules/@types/react/index.d.ts
(2696,13): error TS2403: Subsequent variable declarations must have the same type.  Variable 'map' must be of type 'HTMLProps<HTMLMapElement>', but here has type 'HTMLProps<HTMLMapElement>'.

ERROR in /home/minas/Projects/humorista-website/node_modules/@types/react/index.d.ts
(2697,13): error TS2403: Subsequent variable declarations must have the same type.  Variable 'mark' must be of type 'HTMLProps<HTMLElement>', but here has type 'HTMLProps<HTMLElement>'.

ERROR in /home/minas/Projects/humorista-website/node_modules/@types/react/index.d.ts
(2698,13): error TS2403: Subsequent variable declarations must have the same type.  Variable 'menu' must be of type 'HTMLProps<HTMLElement>', but here has type 'HTMLProps<HTMLElement>'.

ERROR in /home/minas/Projects/humorista-website/node_modules/@types/react/index.d.ts
(2699,13): error TS2403: Subsequent variable declarations must have the same type.  Variable 'menuitem' must be of type 'HTMLProps<HTMLElement>', but here has type 'HTMLProps<HTMLElement>'.

ERROR in /home/minas/Projects/humorista-website/node_modules/@types/react/index.d.ts
(2700,13): error TS2403: Subsequent variable declarations must have the same type.  Variable 'meta' must be of type 'HTMLProps<HTMLMetaElement>', but here has type 'HTMLProps<HTMLMetaElement>'.

ERROR in /home/minas/Projects/humorista-website/node_modules/@types/react/index.d.ts
(2701,13): error TS2403: Subsequent variable declarations must have the same type.  Variable 'meter' must be of type 'HTMLProps<HTMLElement>', but here has type 'HTMLProps<HTMLElement>'.

ERROR in /home/minas/Projects/humorista-website/node_modules/@types/react/index.d.ts
(2702,13): error TS2403: Subsequent variable declarations must have the same type.  Variable 'nav' must be of type 'HTMLProps<HTMLElement>', but here has type 'HTMLProps<HTMLElement>'.

...(有更多错误,但堆栈溢出对字符有限制)

我的package.json看起来像这样:

{
  "name": "humorista-website",
  "version": "1.0.0",
  "description": "",
  "main": "./dist/bundle.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "@types/moment": "^2.13.0",
    "@types/react": "^15.0.4",
    "@types/react-dom": "^0.14.21",
    "@types/react-ga": "^1.4.6",
    "@types/react-redux": "^4.4.36",
    "@types/react-tap-event-plugin": "0.0.30",
    "@types/redux": "^3.6.0",
    "material-ui": "^0.16.4",
    "moment": "^2.16.0",
    "react": "^15.4.2",
    "react-dom": "^15.4.2",
    "react-ga": "^2.1.2",
    "react-infinite-scroller": "^1.0.2",
    "react-redux": "^5.0.2",
    "react-router": "^2.8.1",
    "react-sticky": "^5.0.5",
    "react-tap-event-plugin": "^2.0.1",
    "redux": "^3.6.0"
  },
  "devDependencies": {
    "express": "^4.14.0",
    "path": "^0.12.7",
    "source-map-loader": "^0.1.5",
    "svg-url-loader": "^1.1.0",
    "ts-loader": "^0.8.2",
    "url-loader": "^0.5.7"
  }
}

任何可能导致此问题的想法?

1 个答案:

答案 0 :(得分:2)

遇到此问题的其他人已经两次安装了他们的类型:https://github.com/DefinitelyTyped/DefinitelyTyped/issues/11922

您是否尝试删除@types文件夹,然后再次运行npm install从头开始重新安装?