rt2zz / redux-persist

persist and rehydrate a redux store
MIT License
12.91k stars 862 forks source link

[Typescript suggestion] Stricter type checking for persist config #1401

Open subrapak opened 1 year ago

subrapak commented 1 year ago

Hi! πŸ‘‹

Firstly, thanks for your work on this project! πŸ™‚

Today I used patch-package to patch redux-persist@6.0.0 for the project I'm working on.

Added stricter type checking for the blacklist and whitelist keys in redux-persist config. According to my understanding, this stricter type checking prevents entering invalid keys/strings as blacklist and whitelist, and also provides autocomplete when adding keys. Interested in hearing any thoughts that disagree, or reasons why this might not be a good change to make!

diff --git a/node_modules/redux-persist/types/types.d.ts b/node_modules/redux-persist/types/types.d.ts
index b3733bc..ac7517d 100644
--- a/node_modules/redux-persist/types/types.d.ts
+++ b/node_modules/redux-persist/types/types.d.ts
@@ -31,8 +31,8 @@ declare module "redux-persist/es/types" {
      * @deprecated keyPrefix is going to be removed in v6.
      */
     keyPrefix?: string;
-    blacklist?: Array<string>;
-    whitelist?: Array<string>;
+    blacklist?: Array<keyof S>;
+    whitelist?: Array<keyof S>;
     transforms?: Array<Transform<HSS, ESS, S, RS>>;
     throttle?: number;
     migrate?: PersistMigrate;

This issue body was partially generated by patch-package.