@@ -21,21 +21,21 @@ import isPlainObject from './utils/isPlainObject'
21
21
* parts of the state tree respond to actions, you may combine several reducers
22
22
* into a single reducer function by using `combineReducers`.
23
23
*
24
- * @param { Function } reducer A function that returns the next state tree, given
24
+ * @param reducer A function that returns the next state tree, given
25
25
* the current state tree and the action to handle.
26
26
*
27
- * @param { any } [ preloadedState] The initial state. You may optionally specify it
27
+ * @param preloadedState The initial state. You may optionally specify it
28
28
* to hydrate the state from the server in universal apps, or to restore a
29
29
* previously serialized user session.
30
30
* If you use `combineReducers` to produce the root reducer function, this must be
31
31
* an object with the same shape as `combineReducers` keys.
32
32
*
33
- * @param { Function } [ enhancer] The store enhancer. You may optionally specify it
33
+ * @param enhancer The store enhancer. You may optionally specify it
34
34
* to enhance the store with third-party capabilities such as middleware,
35
35
* time travel, persistence, etc. The only store enhancer that ships with Redux
36
36
* is `applyMiddleware()`.
37
37
*
38
- * @returns { Store } A Redux store that lets you read the state, dispatch actions
38
+ * @returns A Redux store that lets you read the state, dispatch actions
39
39
* and subscribe to changes.
40
40
*/
41
41
export default function createStore <
@@ -97,7 +97,7 @@ export default function createStore<
97
97
throw new Error ( 'Expected the reducer to be a function.' )
98
98
}
99
99
100
- let currentReducer = reducer
100
+ let currentReducer : Reducer < any , any > = reducer
101
101
let currentState = preloadedState as S
102
102
let currentListeners : ( ( ) => void ) [ ] | null = [ ]
103
103
let nextListeners = currentListeners
@@ -119,7 +119,7 @@ export default function createStore<
119
119
/**
120
120
* Reads the state tree managed by the store.
121
121
*
122
- * @returns { any } The current state tree of your application.
122
+ * @returns The current state tree of your application.
123
123
*/
124
124
function getState ( ) : S {
125
125
if ( isDispatching ) {
@@ -153,8 +153,8 @@ export default function createStore<
153
153
* registered before the `dispatch()` started will be called with the latest
154
154
* state by the time it exits.
155
155
*
156
- * @param { Function } listener A callback to be invoked on every dispatch.
157
- * @returns { Function } A function to remove this change listener.
156
+ * @param listener A callback to be invoked on every dispatch.
157
+ * @returns A function to remove this change listener.
158
158
*/
159
159
function subscribe ( listener : ( ) => void ) {
160
160
if ( typeof listener !== 'function' ) {
@@ -210,13 +210,13 @@ export default function createStore<
210
210
* example, see the documentation for the `redux-thunk` package. Even the
211
211
* middleware will eventually dispatch plain object actions using this method.
212
212
*
213
- * @param { Object } action A plain object representing “what changed”. It is
213
+ * @param action A plain object representing “what changed”. It is
214
214
* a good idea to keep actions serializable so you can record and replay user
215
215
* sessions, or use the time travelling `redux-devtools`. An action must have
216
216
* a `type` property which may not be `undefined`. It is a good idea to use
217
217
* string constants for action types.
218
218
*
219
- * @returns { Object } For convenience, the same action object you dispatched.
219
+ * @returns For convenience, the same action object you dispatched.
220
220
*
221
221
* Note that, if you use a custom middleware, it may wrap `dispatch()` to
222
222
* return something else (for example, a Promise you can await).
@@ -263,8 +263,8 @@ export default function createStore<
263
263
* load some of the reducers dynamically. You might also need this if you
264
264
* implement a hot reloading mechanism for Redux.
265
265
*
266
- * @param { Function } nextReducer The reducer for the store to use instead.
267
- * @returns { Store } The same store instance with a new reducer in place.
266
+ * @param nextReducer The reducer for the store to use instead.
267
+ * @returns The same store instance with a new reducer in place.
268
268
*/
269
269
function replaceReducer < NewState , NewActions extends A > (
270
270
nextReducer : Reducer < NewState , NewActions >
@@ -273,11 +273,7 @@ export default function createStore<
273
273
throw new Error ( 'Expected the nextReducer to be a function.' )
274
274
}
275
275
276
- // TODO: do this more elegantly
277
- ; ( ( currentReducer as unknown ) as Reducer <
278
- NewState ,
279
- NewActions
280
- > ) = nextReducer
276
+ currentReducer = nextReducer
281
277
282
278
// This action has a similiar effect to ActionTypes.INIT.
283
279
// Any reducers that existed in both the new and old rootReducer
@@ -296,7 +292,7 @@ export default function createStore<
296
292
297
293
/**
298
294
* Interoperability point for observable/reactive libraries.
299
- * @returns { observable } A minimal observable of state changes.
295
+ * @returns A minimal observable of state changes.
300
296
* For more information, see the observable proposal:
301
297
* https://github.com/tc39/proposal-observable
302
298
*/
@@ -305,9 +301,9 @@ export default function createStore<
305
301
return {
306
302
/**
307
303
* The minimal observable subscription method.
308
- * @param { Object } observer Any object that can be used as an observer.
304
+ * @param observer Any object that can be used as an observer.
309
305
* The observer object should have a `next` method.
310
- * @returns { subscription } An object with an `unsubscribe` method that can
306
+ * @returns An object with an `unsubscribe` method that can
311
307
* be used to unsubscribe the observable from the store, and prevent further
312
308
* emission of values from the observable.
313
309
*/
0 commit comments