Redux-persist: Make dependency on react optional

Created on 29 May 2018  路  3Comments  路  Source: rt2zz/redux-persist

I currently use redux-persist 4.9.1 in an Angular 6 application with angular-cli and angular-redux/store and redux 4.0.0. It is a typescript 2.7 application.
When I upgrade to redux-persist 5.9.1 there is the following error:

 92% after chunk asset optimization SourceMapDevToolPlugin main.js generate SourceMapERROR in node_modules/redux-persist/src/index.d.ts(69,46): error TS2307: Cannot find module 'react'.
node_modules/redux-persist/src/index.d.ts(91,38): error TS2304: Cannot find name 'React'.

It would be good if the integration with react would be optional.

Most helpful comment

At the moment I provide the fake typings for react manually as a workaround:

declare var React;

/* tslint:disable */
declare module 'react' {
  export interface ReactNode {}
  export interface PureComponent {}
}

All 3 comments

At the moment I provide the fake typings for react manually as a workaround:

declare var React;

/* tslint:disable */
declare module 'react' {
  export interface ReactNode {}
  export interface PureComponent {}
}

bump.

@scic thank you so much for the workaround.

The problem persists somehow in Angular 7 at least in version 5.10.0. Here are my project dependencies:

"dependencies": {
    "@angular-redux/form": "^9.0.1",
    "@angular-redux/store": "^9.0.0",
    "@angular/animations": "~7.2.0",
    "@angular/common": "~7.2.0",
    "@angular/compiler": "~7.2.0",
    "@angular/core": "~7.2.0",
    "@angular/forms": "~7.2.0",
    "@angular/platform-browser": "~7.2.0",
    "@angular/platform-browser-dynamic": "~7.2.0",
    "@angular/router": "~7.2.0",
    "core-js": "^2.5.4",
    "flux-standard-action": "^2.0.3",
    "redux": "^4.0.1",
    "redux-persist": "^5.10.0",
    "rxjs": "~6.3.3",
    "tslib": "^1.9.0",
    "zone.js": "~0.8.26"
  },

ERROR in node_modules/redux-persist/src/index.d.ts(70,46): error TS2307: Cannot find module 'react'.
node_modules/redux-persist/src/index.d.ts(92,38): error TS2304: Cannot find name 'React'.

Is someone else facing the same problem with the latest version ?

Was this page helpful?
0 / 5 - 0 ratings