Versions:
TS: 2.7.1
redux-persist: 5.6.5
All of the sub directory imports are not possible when using typescript with redux-persist.
Example:
import storage from 'redux-persist/lib/storage'
// error:
[ts]
Could not find a declaration file for module 'redux-persist/lib/storage'. '.../node_modules/redux-persist/lib/storage/index.js' implicitly has an 'any' type.
Try `npm install @types/redux-persist` if it exists or add a new declaration (.d.ts) file containing `declare module 'redux-persist';`
@ch1ll0ut1 is the issue that our types are not complete or that with deep imports TS does not know where to look for the definitions? FWIW a short term fix would be to use localforage as your storage.
@rt2zz i would guess its missing typings, but cant be sure. From googling it seems it should be possible doing
declare module 'redux-persist/lib/storage' {
...
}
But on the other side, wouldnt it be better exporting the full api on the root module?
got it, I think we were just missing the lib exports for these files (we had them for es), this should resolve: https://github.com/rt2zz/redux-persist/commit/4a00ed8274018d540cbd4e803216c60f94e58d92
error TS4050: Return type of public static method from exported class has or is using name 'Persistor' from external module "redux-persist/es/types" but cannot be named.
@rt2zz I am guessing that this error is related to this,
If so, any date for publishing the fix?
@rt2zz this one as well
node_modules/redux-persist/src/index.d.ts(348,46): error TS2307: Cannot find module 'react'.
Maybe we should add React as peerDeps? No quite sure what is the fix but I am getting this one as well
@yordis I am not sure about these errors - does #706 resolve the first?
For the second it seems like maybe we need to move the type definitions for react integration out of index.d.ts and into the proxy module: https://github.com/rt2zz/redux-persist/tree/master/integration/react
Again I am not a TS user so I can only speculate, but will gladly merge fixes and cut a new release.
@yordis I am not sure about these errors - does #706 resolve the first?
I have "redux-persist": "^5.6.10", is #706 on it?
For the second it seems like maybe we need to move the type definitions for react integration out of index.d.ts and into the proxy module: https://github.com/rt2zz/redux-persist/tree/master/integration/react
I think this issue is related to that you do not have React as peer or direct dependency so, I am not quite sure what should be the right move here.
Getting an error with lib/integration/react as well. Adding this to index.d.ts fixes it.
declare module "redux-persist/lib/integration/react" {
export * from "redux-persist/es/integration/react";
}
ahhh now I understand the error in https://github.com/rt2zz/redux-persist/issues/700#issuecomment-363008955 thanks
adding this to new release now
@i8wu can you try 5.6.11
and change your import from redux-persist/lib/integration/react to redux-persist/integration/react (i.e. drop the lib)
@rt2zz Seems like PersistGate works now...but import storage from "redux-persist/lib/storage" is complaining about `"redux-persist/lib/storage" has no default export
Running:
version: 5.7.2
@types: 4.3.1
When trying to import autoRehydrate:
import { autoRehydrate } from 'redux-persist'
I get the following error:
Module '"redux-persist"' has no exported member 'autoRehydrate'.
redux-persist v5 does not have a autoRehydrate method. Also it ships with its own type definitions so you should not need to install them from a different source.
Hi there ,i have the same problem
v5.6.0
i am using redux-persist in angular5 app, does it work only with react?
thanks for your help
still an issue on "redux-persist": "5.9.1"
npm i --save @types/react clears up the build error.
Most helpful comment
still an issue on "redux-persist": "5.9.1"