@@ -2,7 +2,6 @@ import type {
22 Reducer ,
33 ReducersMapObject ,
44 Middleware ,
5- Action ,
65 StoreEnhancer ,
76 Store ,
87 UnknownAction ,
@@ -39,16 +38,18 @@ import { buildGetDefaultEnhancers } from './getDefaultEnhancers'
3938 */
4039export interface ConfigureStoreOptions <
4140 S = any ,
42- A extends Action = UnknownAction ,
4341 M extends Tuple < Middlewares < S > > = Tuple < Middlewares < S > > ,
4442 E extends Tuple < Enhancers > = Tuple < Enhancers > ,
4543 P = S ,
4644> {
4745 /**
4846 * A single reducer function that will be used as the root reducer, or an
4947 * object of slice reducers that will be passed to `combineReducers()`.
48+ *
49+ * The reducer may be typed to handle any action type - the resulting store
50+ * is always typed to dispatch `UnknownAction`, as recommended.
5051 */
51- reducer : Reducer < S , A , P > | ReducersMapObject < S , A , P >
52+ reducer : Reducer < S , any , P > | ReducersMapObject < S , any , P >
5253
5354 /**
5455 * An array of Redux middleware to install, or a callback receiving `getDefaultMiddleware` and returning a Tuple of middleware.
@@ -105,10 +106,9 @@ type Enhancers = ReadonlyArray<StoreEnhancer>
105106 */
106107export type EnhancedStore <
107108 S = any ,
108- A extends Action = UnknownAction ,
109109 E extends Enhancers = Enhancers ,
110110> = ExtractStoreExtensions < E > &
111- Store < S , A , UnknownIfNonSpecific < ExtractStateExtensions < E > > >
111+ Store < S , UnknownAction , UnknownIfNonSpecific < ExtractStateExtensions < E > > >
112112
113113/**
114114 * A friendly abstraction over the standard Redux `createStore()` function.
@@ -120,13 +120,12 @@ export type EnhancedStore<
120120 */
121121export function configureStore <
122122 S = any ,
123- A extends Action = UnknownAction ,
124123 M extends Tuple < Middlewares < S > > = Tuple < [ ThunkMiddlewareFor < S > ] > ,
125124 E extends Tuple < Enhancers > = Tuple <
126125 [ StoreEnhancer < { dispatch : ExtractDispatchExtensions < M > } > , StoreEnhancer ]
127126 > ,
128127 P = S ,
129- > ( options : ConfigureStoreOptions < S , A , M , E , P > ) : EnhancedStore < S , A , E > {
128+ > ( options : ConfigureStoreOptions < S , M , E , P > ) : EnhancedStore < S , E > {
130129 const getDefaultMiddleware = buildGetDefaultMiddleware < S > ( )
131130
132131 const {
@@ -138,12 +137,16 @@ export function configureStore<
138137 enhancers = undefined ,
139138 } = options || { }
140139
141- let rootReducer : Reducer < S , A , P >
140+ let rootReducer : Reducer < S , UnknownAction , P >
142141
143142 if ( typeof reducer === 'function' ) {
144143 rootReducer = reducer
145144 } else if ( isPlainObject ( reducer ) ) {
146- rootReducer = combineReducers ( reducer ) as unknown as Reducer < S , A , P >
145+ rootReducer = combineReducers ( reducer ) as unknown as Reducer <
146+ S ,
147+ UnknownAction ,
148+ P
149+ >
147150 } else {
148151 throw new Error (
149152 '`reducer` is a required argument, and must be a function or an object of functions that can be passed to combineReducers' ,
0 commit comments