@@ -10,12 +10,16 @@ import {
10
10
} from '../..'
11
11
import 'symbol-observable'
12
12
13
+ type BrandedString = string & { _brand : 'type' }
14
+ const brandedString = 'a string' as BrandedString
15
+
13
16
type State = {
14
17
a : 'a'
15
18
b : {
16
19
c : 'c'
17
20
d : 'd'
18
21
}
22
+ e : BrandedString
19
23
}
20
24
21
25
/* extended state */
@@ -24,7 +28,8 @@ const noExtend: ExtendState<State, never> = {
24
28
b : {
25
29
c : 'c' ,
26
30
d : 'd'
27
- }
31
+ } ,
32
+ e : brandedString
28
33
}
29
34
// typings:expect-error
30
35
const noExtendError : ExtendState < State , never > = {
@@ -33,7 +38,8 @@ const noExtendError: ExtendState<State, never> = {
33
38
c : 'c' ,
34
39
d : 'd'
35
40
} ,
36
- e : 'oops'
41
+ e : brandedString ,
42
+ f : 'oops'
37
43
}
38
44
39
45
const yesExtend : ExtendState < State , { yes : 'we can' } > = {
@@ -42,6 +48,7 @@ const yesExtend: ExtendState<State, { yes: 'we can' }> = {
42
48
c : 'c' ,
43
49
d : 'd'
44
50
} ,
51
+ e : brandedString ,
45
52
yes : 'we can'
46
53
}
47
54
// typings:expect-error
@@ -50,7 +57,8 @@ const yesExtendError: ExtendState<State, { yes: 'we can' }> = {
50
57
b : {
51
58
c : 'c' ,
52
59
d : 'd'
53
- }
60
+ } ,
61
+ e : brandedString
54
62
}
55
63
56
64
interface DerivedAction extends Action {
@@ -64,7 +72,8 @@ const reducer: Reducer<State> = (
64
72
b : {
65
73
c : 'c' ,
66
74
d : 'd'
67
- }
75
+ } ,
76
+ e : brandedString
68
77
} ,
69
78
action : Action
70
79
) : State => {
@@ -77,7 +86,8 @@ const reducerWithAction: Reducer<State, DerivedAction> = (
77
86
b : {
78
87
c : 'c' ,
79
88
d : 'd'
80
- }
89
+ } ,
90
+ e : brandedString
81
91
} ,
82
92
action : DerivedAction
83
93
) : State => {
@@ -95,17 +105,20 @@ const arrayReducer = (state: any[] = []) => state || []
95
105
const storeWithArrayState : Store < any [ ] > = createStore ( arrayReducer )
96
106
const storeWithPreloadedState : Store < State > = createStore ( reducer , {
97
107
a : 'a' ,
98
- b : { c : 'c' , d : 'd' }
108
+ b : { c : 'c' , d : 'd' } ,
109
+ e : brandedString
99
110
} )
100
111
// typings:expect-error
101
112
const storeWithBadPreloadedState : Store < State > = createStore ( reducer , {
102
- b : { c : 'c' }
113
+ b : { c : 'c' } ,
114
+ e : brandedString
103
115
} )
104
116
105
117
const storeWithActionReducer = createStore ( reducerWithAction )
106
118
const storeWithActionReducerAndPreloadedState = createStore ( reducerWithAction , {
107
119
a : 'a' ,
108
- b : { c : 'c' , d : 'd' }
120
+ b : { c : 'c' , d : 'd' } ,
121
+ e : brandedString
109
122
} )
110
123
funcWithStore ( storeWithActionReducer )
111
124
funcWithStore ( storeWithActionReducerAndPreloadedState )
@@ -114,7 +127,8 @@ funcWithStore(storeWithActionReducerAndPreloadedState)
114
127
const storeWithActionReducerAndBadPreloadedState = createStore (
115
128
reducerWithAction ,
116
129
{
117
- b : { c : 'c' }
130
+ b : { c : 'c' } ,
131
+ e : brandedString
118
132
}
119
133
)
120
134
@@ -126,7 +140,8 @@ const storeWithPreloadedStateAndEnhancer: Store<State> = createStore(
126
140
reducer ,
127
141
{
128
142
a : 'a' ,
129
- b : { c : 'c' , d : 'd' }
143
+ b : { c : 'c' , d : 'd' } ,
144
+ e : brandedString
130
145
} ,
131
146
enhancer
132
147
)
0 commit comments