Repository navigation
Commit bdf39a7
authored
refactor(store): improve store types (#763)
* refactor(store): improve store types
store.ts
`NotWrappable` now consists of all non-object/array types.
Simplified `DeepReadonly<T>`.
Simplified `StoreNode`.
`Store<T>` is now an alias for `DeepReadonly<T>`.
Refactored `Part`, `Next`, and `SetStoreFunction` to improve their performance.
Changed `NullableNext` to `Next`, and `Next` to `WrappableNext`. `WrappableNext` excludes all non-wrappable types instead of just non-nullable types, so `{a: number | {b: number}}` now allows `setStore("a", "b", 1)`.
Improved the rest overload for `SetStoreFunction<T>`: it now correctly infers all types in the correct order, except for `ArrayFilterFn`s which need to be explicitly typed.
store.spec.ts
Added a few type test cases for store types.
modifiers.ts
Improved types of `reconcile` and `produce`; the latter now correctly infers types.
modifiers.spec.ts
Allow `produce` calls to have their types inferred.
server.ts
Import types from store.ts instead of redefining them.
mutable.ts
Return `T` instead of `Store<T>`, as the latter is no longer writable.
index.ts
Removed the `Readonly` export. Added `WrappableNext`.
fixes #732
* test(store): enable store tests and fix failing tests1 parent 742d412 commit bdf39a7
8 files changed
Lines changed: 408 additions & 330 deletions
File tree
- packages/solid
- store
- src
- test
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
| 12 | + | |
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
| 16 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
2 | | - | |
3 | | - | |
4 | | - | |
5 | | - | |
6 | | - | |
7 | | - | |
8 | | - | |
9 | | - | |
10 | | - | |
| 1 | + | |
11 | 2 | | |
12 | 3 | | |
13 | 4 | | |
| |||
113 | 104 | | |
114 | 105 | | |
115 | 106 | | |
116 | | - | |
| 107 | + | |
117 | 108 | | |
118 | | - | |
119 | | - | |
120 | | - | |
| 109 | + | |
121 | 110 | | |
122 | 111 | | |
123 | | - | |
124 | | - | |
125 | | - | |
| 112 | + | |
| 113 | + | |
126 | 114 | | |
127 | | - | |
| 115 | + | |
128 | 116 | | |
129 | 117 | | |
130 | 118 | | |
| |||
147 | 135 | | |
148 | 136 | | |
149 | 137 | | |
150 | | - | |
151 | | - | |
152 | | - | |
153 | | - | |
154 | | - | |
155 | | - | |
156 | | - | |
| 138 | + | |
| 139 | + | |
157 | 140 | | |
158 | 141 | | |
159 | 142 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
12 | 11 | | |
13 | 12 | | |
14 | 13 | | |
| |||
52 | 51 | | |
53 | 52 | | |
54 | 53 | | |
55 | | - | |
| 54 | + | |
56 | 55 | | |
57 | 56 | | |
58 | 57 | | |
| |||
79 | 78 | | |
80 | 79 | | |
81 | 80 | | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
| 81 | + | |
86 | 82 | | |
87 | 83 | | |
88 | 84 | | |
| |||
92 | 88 | | |
93 | 89 | | |
94 | 90 | | |
95 | | - | |
| 91 | + | |
96 | 92 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
2 | | - | |
3 | | - | |
4 | | - | |
5 | | - | |
6 | | - | |
7 | | - | |
| 1 | + | |
8 | 2 | | |
9 | | - | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
| 3 | + | |
16 | 4 | | |
17 | 5 | | |
18 | 6 | | |
| |||
87 | 75 | | |
88 | 76 | | |
89 | 77 | | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | | - | |
107 | | - | |
108 | | - | |
109 | | - | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | | - | |
119 | | - | |
120 | | - | |
121 | | - | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | | - | |
126 | | - | |
127 | | - | |
128 | | - | |
129 | | - | |
130 | | - | |
131 | | - | |
132 | | - | |
133 | | - | |
134 | | - | |
135 | | - | |
136 | | - | |
137 | | - | |
138 | | - | |
139 | | - | |
140 | | - | |
141 | | - | |
142 | | - | |
143 | | - | |
144 | | - | |
145 | | - | |
146 | | - | |
147 | | - | |
148 | | - | |
149 | | - | |
150 | | - | |
151 | | - | |
152 | | - | |
153 | | - | |
154 | | - | |
155 | | - | |
156 | | - | |
157 | | - | |
158 | | - | |
159 | | - | |
160 | | - | |
161 | | - | |
162 | | - | |
163 | | - | |
164 | | - | |
165 | | - | |
166 | | - | |
167 | | - | |
168 | | - | |
169 | | - | |
170 | | - | |
171 | | - | |
172 | | - | |
173 | | - | |
174 | | - | |
175 | | - | |
176 | | - | |
177 | | - | |
178 | | - | |
179 | | - | |
180 | | - | |
181 | | - | |
182 | | - | |
183 | | - | |
184 | | - | |
185 | | - | |
186 | | - | |
187 | | - | |
188 | | - | |
189 | | - | |
190 | | - | |
191 | | - | |
192 | 78 | | |
193 | 79 | | |
194 | 80 | | |
195 | 81 | | |
196 | 82 | | |
197 | 83 | | |
198 | 84 | | |
199 | | - | |
200 | | - | |
201 | | - | |
| 85 | + | |
202 | 86 | | |
203 | 87 | | |
204 | 88 | | |
| |||
211 | 95 | | |
212 | 96 | | |
213 | 97 | | |
214 | | - | |
| 98 | + | |
215 | 99 | | |
216 | 100 | | |
217 | 101 | | |
| |||
228 | 112 | | |
229 | 113 | | |
230 | 114 | | |
231 | | - | |
232 | | - | |
233 | | - | |
| 115 | + | |
234 | 116 | | |
235 | 117 | | |
236 | 118 | | |
| |||
0 commit comments