@@ -65,7 +65,10 @@ describe('useStore', () => {
65
65
} ) ;
66
66
67
67
it ( 'should allow to update the value' , ( ) => {
68
- const { useStore} = createStore ( ) ;
68
+ type Store = {
69
+ items : number [ ] ;
70
+ }
71
+ const { useStore} = createStore < Store > ( ) ;
69
72
70
73
function Test ( ) {
71
74
const [ items , setItems ] = useStore . items ( [ ] ) ;
@@ -88,8 +91,18 @@ describe('useStore', () => {
88
91
} ) ;
89
92
90
93
it ( 'should be possible to create more than one store' , ( ) => {
91
- const { useStore : useCart , getStore : getCart } = createStore ( { items : [ ] } ) ;
92
- const { useStore : useCounter } = createStore ( { count : 0 } ) ;
94
+ type CartStore = {
95
+ items : string [ ] ;
96
+ }
97
+
98
+ type CounterStore = {
99
+ count : number ;
100
+ }
101
+
102
+ const { useStore : useCart , getStore : getCart } = createStore < CartStore > ( {
103
+ items : [ ]
104
+ } ) ;
105
+ const { useStore : useCounter } = createStore < CounterStore > ( { count : 0 } ) ;
93
106
94
107
function Test ( ) {
95
108
const [ count ] = useCounter . count ( ) ;
@@ -120,14 +133,23 @@ describe('useStore', () => {
120
133
121
134
it ( 'should work changing the index of an array on fly' , ( ) => {
122
135
const onAfterUpdate = jest . fn ( ) ;
123
- const { useStore} = createStore ( {
136
+ type Items = {
137
+ price : number ;
138
+ name : string ;
139
+ }
140
+ type Store = {
141
+ cart : {
142
+ items : Items [ ] ;
143
+ }
144
+ }
145
+ const { useStore} = createStore < Store > ( {
124
146
cart : {
125
147
items : [ ] ,
126
148
} ,
127
149
} , onAfterUpdate ) ;
128
150
129
151
function Test ( ) {
130
- const [ state , setState ] = useState ( 0 ) ;
152
+ const [ state , setState ] = useState < number > ( 0 ) ;
131
153
const [ item , setItem ] = useStore . cart . items [ state ] ( ) ;
132
154
133
155
return (
0 commit comments