@@ -2,82 +2,12 @@ import { AnyAction, Action, Reducer } from '..'
2
2
import ActionTypes from './utils/actionTypes'
3
3
import warning from './utils/warning'
4
4
import isPlainObject from './utils/isPlainObject'
5
-
6
- /**
7
- * Internal "virtual" symbol used to make the `CombinedState` type unique.
8
- */
9
- declare const $CombinedState : unique symbol
10
-
11
- /**
12
- * State base type for reducers created with `combineReducers()`.
13
- *
14
- * This type allows the `createStore()` method to infer which levels of the
15
- * preloaded state can be partial.
16
- *
17
- * Because Typescript is really duck-typed, a type needs to have some
18
- * identifying property to differentiate it from other types with matching
19
- * prototypes for type checking purposes. That's why this type has the
20
- * `$CombinedState` symbol property. Without the property, this type would
21
- * match any object. The symbol doesn't really exist because it's an internal
22
- * (i.e. not exported), and internally we never check its value. Since it's a
23
- * symbol property, it's not expected to be unumerable, and the value is
24
- * typed as always undefined, so its never expected to have a meaningful
25
- * value anyway. It just makes this type distinquishable from plain `{}`.
26
- */
27
- export type CombinedState < S > = { readonly [ $CombinedState ] ?: undefined } & S
28
-
29
- /**
30
- * Object whose values correspond to different reducer functions.
31
- *
32
- * @template A The type of actions the reducers can potentially respond to.
33
- */
34
- export type ReducersMapObject < S = any , A extends Action = Action > = {
35
- [ K in keyof S ] : Reducer < S [ K ] , A >
36
- }
37
-
38
- /**
39
- * Infer a combined state shape from a `ReducersMapObject`.
40
- *
41
- * @template M Object map of reducers as provided to `combineReducers(map: M)`.
42
- */
43
- export type StateFromReducersMapObject < M > = M extends ReducersMapObject <
44
- any ,
45
- any
46
- >
47
- ? { [ P in keyof M ] : M [ P ] extends Reducer < infer S , any > ? S : never }
48
- : never
49
-
50
- /**
51
- * Infer action type from a reducer function.
52
- *
53
- * @template R Type of reducer.
54
- */
55
- export type ActionFromReducer < R > = R extends Reducer < any , infer A > ? A : never
56
-
57
- /**
58
- * Infer action union type from a `ReducersMapObject`.
59
- *
60
- * @template M Object map of reducers as provided to `combineReducers(map: M)`.
61
- */
62
- export type ActionFromReducersMapObject < M > = M extends ReducersMapObject <
63
- any ,
64
- any
65
- >
66
- ? ActionFromReducer < ReducerFromReducersMapObject < M > >
67
- : never
68
-
69
- /**
70
- * Infer reducer union type from a `ReducersMapObject`.
71
- *
72
- * @template M Object map of reducers as provided to `combineReducers(map: M)`.
73
- */
74
- export type ReducerFromReducersMapObject < M > = M extends {
75
- [ P in keyof M ] : infer R
76
- }
77
- ? R extends Reducer < any , any >
78
- ? R
79
- : never
80
- : never
5
+ import {
6
+ ReducersMapObject ,
7
+ CombinedState ,
8
+ StateFromReducersMapObject ,
9
+ ActionFromReducersMapObject
10
+ } from './types/reducers'
81
11
82
12
function getUndefinedStateErrorMessage ( key : string , action : Action ) {
83
13
const actionType = action && action . type
0 commit comments