aspnet / JavaScriptServices

[Archived] This repository has been archived
Apache License 2.0
3.03k stars 518 forks source link

React with Redux show many errors when creating #582

Closed sad1y closed 7 years ago

sad1y commented 7 years ago

It is normal that this happens?

npm WARN optional Skipping failed optional dependency /chokidar/fsevents:
npm WARN notsup Not compatible with your operating system or architecture: fsevents@1.0.17
npm WARN ReactRedux@0.0.0 No description
npm WARN ReactRedux@0.0.0 No repository field.
npm WARN ReactRedux@0.0.0 No license field.
log  : Restoring packages for z:\projects\temp\ReactRedux\project.json...
log  : Restoring packages for tool 'Microsoft.AspNetCore.Razor.Tools' in z:\projects\temp\ReactRedux\project.json...
log  : Restoring packages for tool 'Microsoft.AspNetCore.Server.IISIntegration.Tools' in z:\projects\temp\ReactRedux\project.json...
log  : Restoring packages for tool 'Microsoft.DotNet.Watcher.Tools' in z:\projects\temp\ReactRedux\project.json...
log  : Writing lock file to disk. Path: z:\projects\temp\ReactRedux\project.lock.json
log  : z:\projects\temp\ReactRedux\project.json
log  : Restore completed in 5476ms.
Hash: 9e03fe6cec5d8398598c3aab4069bb548ad173b3
Version: webpack 1.14.0
Child
    Hash: 9e03fe6cec5d8398598c
    Version: webpack 1.14.0
    Time: 3651ms
                                   Asset     Size  Chunks             Chunk Names
    89889688147bd7575d6327160d64e760.svg   109 kB          [emitted]
                               vendor.js  1.73 MB       0  [emitted]  vendor
                              vendor.css   315 kB       0  [emitted]  vendor
       [0] dll vendor 12 bytes {0} [built]
        + 374 hidden modules

    WARNING in ./~/node-libs-browser/~/process/browser.js
    There is another module with an equal name when case is ignored.
    This can lead to unexpected behavior when compiling on a filesystem with other case-semantic.
    Rename module if multiple modules are expected or use equal casing if one module is expected.

    WARNING in Z:/projects/temp/ReactRedux/~/node-libs-browser/~/process/browser.js
    There is another module with an equal name when case is ignored.
    This can lead to unexpected behavior when compiling on a filesystem with other case-semantic.
    Rename module if multiple modules are expected or use equal casing if one module is expected.
    Child extract-text-webpack-plugin:
            + 7 hidden modules
Child
    Hash: 3aab4069bb548ad173b3
    Version: webpack 1.14.0
    Time: 3638ms
                                   Asset     Size  Chunks             Chunk Names
    89889688147bd7575d6327160d64e760.svg   109 kB          [emitted]
                               vendor.js  1.97 MB       0  [emitted]  vendor
       [0] dll vendor 12 bytes {0} [built]
        + 352 hidden modules
Hash: fc566f2f18fd46265e2059f70807ccc31b057bb8
Version: webpack 1.14.0
Child
    Hash: fc566f2f18fd46265e20
    Version: webpack 1.14.0
    Time: 4003ms
                 Asset      Size  Chunks             Chunk Names
        main-client.js   43.4 kB       0  [emitted]  main-client
              site.css   1.56 kB       0  [emitted]  main-client
    main-client.js.map   30.3 kB       0  [emitted]  main-client
          site.css.map  85 bytes       0  [emitted]  main-client
        + 23 hidden modules

    ERROR in Z:\projects\temp\ReactRedux\node_modules\typescript\lib\lib.dom.d.ts
    (7552,11): error TS2300: Duplicate identifier 'History'.

    ERROR in Z:\projects\temp\ReactRedux\node_modules\typescript\lib\lib.dom.d.ts
    (7562,13): error TS2300: Duplicate identifier 'History'.

    ERROR in z:\projects\temp\ReactRedux\node_modules\@types\react-router-redux\node_modules\@types\history\index.d.ts
    (6,21): error TS2300: Duplicate identifier 'History'.

    ERROR in z:\projects\temp\ReactRedux\node_modules\@types\react-router\lib\createMemoryHistory.d.ts
    (3,57): error TS2305: Module '"z:/projects/temp/ReactRedux/node_modules/@types/history/index"' has no exported member 'HistoryOptions'.

    ERROR in z:\projects\temp\ReactRedux\node_modules\@types\react-router\lib\useRouterHistory.d.ts
    (1,19): error TS2305: Module '"z:/projects/temp/ReactRedux/node_modules/@types/history/index"' has no exported member 'HistoryOptions'.

    ERROR in z:\projects\temp\ReactRedux\node_modules\@types\react-router\lib\useRouterHistory.d.ts
    (1,35): error TS2305: Module '"z:/projects/temp/ReactRedux/node_modules/@types/history/index"' has no exported member 'HistoryQueries'.

    ERROR in z:\projects\temp\ReactRedux\node_modules\@types\react-router\lib\useRouterHistory.d.ts
    (1,51): error TS2305: Module '"z:/projects/temp/ReactRedux/node_modules/@types/history/index"' has no exported member 'CreateHistory'.

    ERROR in z:\projects\temp\ReactRedux\node_modules\@types\react-router\lib\useRoutes.d.ts
    (4,48): error TS2305: Module '"z:/projects/temp/ReactRedux/node_modules/@types/history/index"' has no exported member 'CreateHistory'.

    ERROR in z:\projects\temp\ReactRedux\node_modules\@types\react-router\lib\useRoutes.d.ts
    (4,69): error TS2305: Module '"z:/projects/temp/ReactRedux/node_modules/@types/history/index"' has no exported member 'CreateHistory'.

    ERROR in z:\projects\temp\ReactRedux\node_modules\@types\react-router\lib\routerHistory.d.ts
    (10,46): error TS2305: Module '"z:/projects/temp/ReactRedux/node_modules/@types/history/index"' has no exported member 'Query'.

    ERROR in z:\projects\temp\ReactRedux\node_modules\@types\react-router\lib\routerHistory.d.ts
    (20,39): error TS2305: Module '"z:/projects/temp/ReactRedux/node_modules/@types/history/index"' has no exported member 'HistoryQueries'.

    ERROR in z:\projects\temp\ReactRedux\node_modules\@types\react-router\lib\Redirect.d.ts
    (14,19): error TS2305: Module '"z:/projects/temp/ReactRedux/node_modules/@types/history/index"' has no exported member 'Query'.

    ERROR in z:\projects\temp\ReactRedux\node_modules\@types\react-router\lib\IndexRedirect.d.ts
    (12,16): error TS2305: Module '"z:/projects/temp/ReactRedux/node_modules/@types/history/index"' has no exported member 'Query'.

    ERROR in z:\projects\temp\ReactRedux\node_modules\@types\react-router\lib\Router.d.ts
    (4,5): error TS2305: Module '"z:/projects/temp/ReactRedux/node_modules/@types/history/index"' has no exported member 'QueryString'.

    ERROR in z:\projects\temp\ReactRedux\node_modules\@types\react-router\lib\Router.d.ts
    (4,18): error TS2305: Module '"z:/projects/temp/ReactRedux/node_modules/@types/history/index"' has no exported member 'Query'.

    ERROR in z:\projects\temp\ReactRedux\node_modules\@types\react-router\lib\Router.d.ts
    (112,56): error TS2305: Module '"z:/projects/temp/ReactRedux/node_modules/@types/history/index".History' has no exported member 'Query'.

    ERROR in z:\projects\temp\ReactRedux\node_modules\@types\react-router\lib\Router.d.ts
    (113,56): error TS2305: Module '"z:/projects/temp/ReactRedux/node_modules/@types/history/index".History' has no exported member 'Query'.

    ERROR in z:\projects\temp\ReactRedux\node_modules\@types\history\index.d.ts
    (5,21): error TS2300: Duplicate identifier 'History'.

    ERROR in z:\projects\temp\ReactRedux\ClientApp\boot-server.tsx
    (5,33): error TS2307: Cannot find module 'history/lib/createMemoryHistory'.

    ERROR in ./ClientApp/boot-client.tsx
    (21,17): error TS2322: Type 'ReactRouterReduxHistory' is not assignable to type 'History'.

    ERROR in ./ClientApp/boot-client.tsx
    (21,17): error TS2322: Type 'ReactRouterReduxHistory' is not assignable to type 'History'.
      Property 'length' is missing in type 'ReactRouterReduxHistory'.
    Child extract-text-webpack-plugin:
            + 2 hidden modules
Child
    Hash: 59f70807ccc31b057bb8
    Version: webpack 1.14.0
    Time: 3991ms
             Asset     Size  Chunks             Chunk Names
    main-server.js  86.3 kB       0  [emitted]  main-server
        + 21 hidden modules

    ERROR in Z:\projects\temp\ReactRedux\node_modules\typescript\lib\lib.dom.d.ts
    (7552,11): error TS2300: Duplicate identifier 'History'.

    ERROR in Z:\projects\temp\ReactRedux\node_modules\typescript\lib\lib.dom.d.ts
    (7562,13): error TS2300: Duplicate identifier 'History'.

    ERROR in z:\projects\temp\ReactRedux\node_modules\@types\react-router-redux\node_modules\@types\history\index.d.ts
    (6,21): error TS2300: Duplicate identifier 'History'.

    ERROR in z:\projects\temp\ReactRedux\node_modules\@types\react-router\lib\createMemoryHistory.d.ts
    (3,57): error TS2305: Module '"z:/projects/temp/ReactRedux/node_modules/@types/history/index"' has no exported member 'HistoryOptions'.

    ERROR in z:\projects\temp\ReactRedux\node_modules\@types\react-router\lib\useRouterHistory.d.ts
    (1,19): error TS2305: Module '"z:/projects/temp/ReactRedux/node_modules/@types/history/index"' has no exported member 'HistoryOptions'.

    ERROR in z:\projects\temp\ReactRedux\node_modules\@types\react-router\lib\useRouterHistory.d.ts
    (1,35): error TS2305: Module '"z:/projects/temp/ReactRedux/node_modules/@types/history/index"' has no exported member 'HistoryQueries'.

    ERROR in z:\projects\temp\ReactRedux\node_modules\@types\react-router\lib\useRouterHistory.d.ts
    (1,51): error TS2305: Module '"z:/projects/temp/ReactRedux/node_modules/@types/history/index"' has no exported member 'CreateHistory'.

    ERROR in z:\projects\temp\ReactRedux\node_modules\@types\react-router\lib\useRoutes.d.ts
    (4,48): error TS2305: Module '"z:/projects/temp/ReactRedux/node_modules/@types/history/index"' has no exported member 'CreateHistory'.

    ERROR in z:\projects\temp\ReactRedux\node_modules\@types\react-router\lib\useRoutes.d.ts
    (4,69): error TS2305: Module '"z:/projects/temp/ReactRedux/node_modules/@types/history/index"' has no exported member 'CreateHistory'.

    ERROR in z:\projects\temp\ReactRedux\node_modules\@types\react-router\lib\routerHistory.d.ts
    (10,46): error TS2305: Module '"z:/projects/temp/ReactRedux/node_modules/@types/history/index"' has no exported member 'Query'.

    ERROR in z:\projects\temp\ReactRedux\node_modules\@types\react-router\lib\routerHistory.d.ts
    (20,39): error TS2305: Module '"z:/projects/temp/ReactRedux/node_modules/@types/history/index"' has no exported member 'HistoryQueries'.

    ERROR in z:\projects\temp\ReactRedux\node_modules\@types\react-router\lib\Redirect.d.ts
    (14,19): error TS2305: Module '"z:/projects/temp/ReactRedux/node_modules/@types/history/index"' has no exported member 'Query'.

    ERROR in z:\projects\temp\ReactRedux\node_modules\@types\react-router\lib\IndexRedirect.d.ts
    (12,16): error TS2305: Module '"z:/projects/temp/ReactRedux/node_modules/@types/history/index"' has no exported member 'Query'.

    ERROR in z:\projects\temp\ReactRedux\node_modules\@types\react-router\lib\Router.d.ts
    (4,5): error TS2305: Module '"z:/projects/temp/ReactRedux/node_modules/@types/history/index"' has no exported member 'QueryString'.

    ERROR in z:\projects\temp\ReactRedux\node_modules\@types\react-router\lib\Router.d.ts
    (4,18): error TS2305: Module '"z:/projects/temp/ReactRedux/node_modules/@types/history/index"' has no exported member 'Query'.

    ERROR in z:\projects\temp\ReactRedux\node_modules\@types\react-router\lib\Router.d.ts
    (112,56): error TS2305: Module '"z:/projects/temp/ReactRedux/node_modules/@types/history/index".History' has no exported member 'Query'.

    ERROR in z:\projects\temp\ReactRedux\node_modules\@types\react-router\lib\Router.d.ts
    (113,56): error TS2305: Module '"z:/projects/temp/ReactRedux/node_modules/@types/history/index".History' has no exported member 'Query'.

    ERROR in z:\projects\temp\ReactRedux\node_modules\@types\history\index.d.ts
    (5,21): error TS2300: Duplicate identifier 'History'.

    ERROR in ./ClientApp/boot-server.tsx
    (5,33): error TS2307: Cannot find module 'history/lib/createMemoryHistory'.

    ERROR in z:\projects\temp\ReactRedux\ClientApp\boot-client.tsx
    (21,17): error TS2322: Type 'ReactRouterReduxHistory' is not assignable to type 'History'.

    ERROR in z:\projects\temp\ReactRedux\ClientApp\boot-client.tsx
    (21,17): error TS2322: Type 'ReactRouterReduxHistory' is not assignable to type 'History'.
      Property 'length' is missing in type 'ReactRouterReduxHistory'.
ryhled commented 7 years ago

No thats not normal and i noticed it as well today when generating a new template after having updated yo & aspnetcore-spa generator.

I tried copying my old node_modules from a week old project (same package file), replacing the ones downloaded in the new project and the errors disappeared.

SapientGuardian commented 7 years ago

I've also run into this. I had to make the following adjustments to my package.json to get things working again:

    "@types/react-router": "2.0.42",
    "@types/react-router-redux": "4.0.36",
    "@types/history": "2.0.44",
MarkPieszak commented 7 years ago

I'm looking into it now, previously react-router-redux had some typings issues in it's declaration files. https://github.com/DefinitelyTyped/DefinitelyTyped/issues/10686#event-921092256, which then the fixes got merged in https://github.com/DefinitelyTyped/DefinitelyTyped/pull/13642 a few days ago.

The template is using "@types/react-router-redux": "^4.0.30", with ^ so it picks up the latest version.

So the History (@types/history) definition files had some serious updates recently: you can see them in this commit, https://github.com/DefinitelyTyped/DefinitelyTyped/commit/a1abf4fd44d411c689300f1c9fa99dc83e4de091

So although the react-redux-router types fixes would have helped, the 2 are now colliding.

@SapientGuardian is correct in that the types should be pinned for now.

Just made a PR for it here #586

davetemplin commented 7 years ago

Hmm, just wondering if the the problem is in @types/react-router-redux or @types/react-router?

$ npm install @types/react-router-redux
`-- @types/react-router-redux@4.0.38
  +-- @types/history@2.0.45
  +-- @types/react-router@2.0.44
  | `-- @types/react@15.0.0
  `-- redux@3.6.0
    +-- lodash@4.17.4
    +-- lodash-es@4.17.4
    +-- loose-envify@1.3.1
    | `-- js-tokens@3.0.0
    `-- symbol-observable@1.0.4

...got @types/history@2.0.45 as expected

$ npm install @types/react-router
`-- @types/react-router@2.0.44
  +-- @types/history@4.5.0
  `-- @types/react@15.0.0

...got @types/history@4.5.0, expected @types/history@2.0.45

Also noticed the following in the package.json for @types/react-router...

  "version": "2.0.44",
  "dependencies":
  {
    "@types/history": "*",
    "@types/react": "*"
  }, ...

Could another way to fix be to set "@types/history": "~2.0.44" instead? Where are these dependent versions set for @types?

olafurw commented 7 years ago

Yup I have the same issue, seems to be installing version 4.x.x, fixed temporarily on my end by adding

"@types/history": "^2.0.44"

to my own dependency list.

SteveSandersonMS commented 7 years ago

Thanks for reporting this. Fixed in f8714e9.

aleksfront commented 7 years ago

@olafurw Thanks!

olafurw commented 7 years ago

Anytime Chuck Norris.

mcquiggd commented 7 years ago

@SteveSandersonMS

Quick question - will the published Yo generator be updated shortly with this fix, or do I have to be a bit more patient? ;) (Updated my copy just now but problem persists).

Edit:

Just copied the changed files from your commit f8714e9 into the relevant locations (on windows):

C:\Users\{Username}\AppData\Roaming\npm\node_modules\generator-aspnetcore-spa\app\templates\

All working - very happy 👍