From 1d3dfcb279deb9ba33438ae5cb03acf1932f3872 Mon Sep 17 00:00:00 2001 From: Brian Chen Date: Wed, 8 Jun 2022 18:17:12 +1000 Subject: [PATCH 1/3] fix type breaking --- .../flow_v0.104.x-/test_toolkit_v1.x.x.js | 36 +++++++++++++++++++ .../flow_v0.104.x-/toolkit_v1.x.x.js | 7 ++-- 2 files changed, 39 insertions(+), 4 deletions(-) diff --git a/definitions/npm/@reduxjs/toolkit_v1.x.x/flow_v0.104.x-/test_toolkit_v1.x.x.js b/definitions/npm/@reduxjs/toolkit_v1.x.x/flow_v0.104.x-/test_toolkit_v1.x.x.js index e1f62e2750..f9995ea561 100644 --- a/definitions/npm/@reduxjs/toolkit_v1.x.x/flow_v0.104.x-/test_toolkit_v1.x.x.js +++ b/definitions/npm/@reduxjs/toolkit_v1.x.x/flow_v0.104.x-/test_toolkit_v1.x.x.js @@ -5,6 +5,8 @@ import { createReducer, configureStore, type Middleware, + type Store, + type Action, } from '@reduxjs/toolkit'; describe('@redux/toolkit', () => { @@ -63,6 +65,40 @@ describe('@redux/toolkit', () => { configureStore({ reducer, }); + + const store: Store<{ + test: { ... }, + test2: number, + ... + }, Action<{ ... }>> = configureStore({ + reducer: { + test: (a) => ({}), + test2: (a) => 2, + }, + }); + + const failedStore: Store<{ + test: { ... }, + test2: string, + ... + }, Action<{ ... }>> = configureStore({ + reducer: { + test: (a) => ({}), + test2: (a) => 2, + }, + }); + + const failedStore2: Store<{| + test: { ... }, + test2: number, + // $FlowExpectedError[prop-missing] foo is missing + |}, Action<{ ... }>> = configureStore({ + reducer: { + test: (a) => ({}), + test2: (a) => 2, + foo: () => 'bar', + }, + }); }); test('full example', () => { diff --git a/definitions/npm/@reduxjs/toolkit_v1.x.x/flow_v0.104.x-/toolkit_v1.x.x.js b/definitions/npm/@reduxjs/toolkit_v1.x.x/flow_v0.104.x-/toolkit_v1.x.x.js index b3748382a9..0ed4218446 100644 --- a/definitions/npm/@reduxjs/toolkit_v1.x.x/flow_v0.104.x-/toolkit_v1.x.x.js +++ b/definitions/npm/@reduxjs/toolkit_v1.x.x/flow_v0.104.x-/toolkit_v1.x.x.js @@ -423,6 +423,8 @@ declare module '@reduxjs/toolkit' { */ declare type ConfigureEnhancersCallback = (defaultEnhancers: $ReadOnlyArray>) => Array>; + declare type ReducersMapObject = (V) => Reducer; + /** * Options for `configureStore()`. */ @@ -431,10 +433,7 @@ declare module '@reduxjs/toolkit' { * A single reducer function that will be used as the root reducer, or an * object of slice reducers that will be passed to `combineReducers()`. */ - reducer: Reducer | { - [key: string]: Reducer, - ... - }, + reducer: Reducer | $ObjMap, /** * An array of Redux middleware to install. If not supplied, defaults to * the set of middleware returned by `getDefaultMiddleware()`. From 5a9a54a6e076031a0206c6d0562618bfcbffe02b Mon Sep 17 00:00:00 2001 From: Brian Chen Date: Thu, 9 Jun 2022 05:51:48 +1000 Subject: [PATCH 2/3] fix the middlwares type --- .../@reduxjs/toolkit_v1.x.x/flow_v0.104.x-/toolkit_v1.x.x.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/definitions/npm/@reduxjs/toolkit_v1.x.x/flow_v0.104.x-/toolkit_v1.x.x.js b/definitions/npm/@reduxjs/toolkit_v1.x.x/flow_v0.104.x-/toolkit_v1.x.x.js index 0ed4218446..c7b4794196 100644 --- a/definitions/npm/@reduxjs/toolkit_v1.x.x/flow_v0.104.x-/toolkit_v1.x.x.js +++ b/definitions/npm/@reduxjs/toolkit_v1.x.x/flow_v0.104.x-/toolkit_v1.x.x.js @@ -49,7 +49,7 @@ declare module '@reduxjs/toolkit' { // -------------------- - declare type Middlewares = $ReadOnlyArray>; + declare type Middlewares = $ReadOnlyArray>; declare type DevToolsOptions = {| /** @@ -423,7 +423,7 @@ declare module '@reduxjs/toolkit' { */ declare type ConfigureEnhancersCallback = (defaultEnhancers: $ReadOnlyArray>) => Array>; - declare type ReducersMapObject = (V) => Reducer; + declare type ReducersMapObject = (V) => Reducer>; /** * Options for `configureStore()`. From 128d459ce5e4561d29e9be6dd0cb2e6ab3d77edf Mon Sep 17 00:00:00 2001 From: Brian Chen Date: Thu, 9 Jun 2022 05:53:28 +1000 Subject: [PATCH 3/3] comment out unusable test --- .../flow_v0.104.x-/test_toolkit_v1.x.x.js | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/definitions/npm/@reduxjs/toolkit_v1.x.x/flow_v0.104.x-/test_toolkit_v1.x.x.js b/definitions/npm/@reduxjs/toolkit_v1.x.x/flow_v0.104.x-/test_toolkit_v1.x.x.js index f9995ea561..8635bf11f8 100644 --- a/definitions/npm/@reduxjs/toolkit_v1.x.x/flow_v0.104.x-/test_toolkit_v1.x.x.js +++ b/definitions/npm/@reduxjs/toolkit_v1.x.x/flow_v0.104.x-/test_toolkit_v1.x.x.js @@ -77,18 +77,7 @@ describe('@redux/toolkit', () => { }, }); - const failedStore: Store<{ - test: { ... }, - test2: string, - ... - }, Action<{ ... }>> = configureStore({ - reducer: { - test: (a) => ({}), - test2: (a) => 2, - }, - }); - - const failedStore2: Store<{| + const failedStore: Store<{| test: { ... }, test2: number, // $FlowExpectedError[prop-missing] foo is missing @@ -99,6 +88,18 @@ describe('@redux/toolkit', () => { foo: () => 'bar', }, }); + + // const failedStore2: Store<{ + // test: { ... }, + // // Expect this to fail but currently does not + // test2: string, + // ... + // }, Action<{ ... }>> = configureStore({ + // reducer: { + // test: (a) => ({}), + // test2: (a) => 2, + // }, + // }); }); test('full example', () => {