Repository navigation
Commit 95d063c
committed
refactor(store): improve store types
This PR focuses more on the performance and inference issues the store types have.
It is not meant to be a complete typing overhaul.
Added `bigint` to `NotWrappable`.
`Store` was quite complicated and often confusing as it contained properties specific to the Store implementation.
However, most internal functions use `StoreNode`. As such `Store<T>` has been repurposed to simply be `DeepReadonly<T>`.
`DeepReadonly` has been simplified.
The Setter type is mostly unchanged externally, except:
- Only `number` is allowed to index Array types (before, for example Array methods and properties were allowed).
- The fallback overload is now much better and correctly constrains types but requires type annotations (they can't be inferred).
- All functions passed via the setter have parameters typed readonly as they should(?) be.
I tried to optimize the Setter as much as possible, and I think it's better at the same number of overloads but don't have any definitive proof of that.
`produce` is now able to infer types correctly from the `setStore` call.
It currently uses a `DeepMutable` type to circumvent `DeepReadonly` being part of the inferred input; the DeepReadonly part shouldn't be inferred.
fixes solidjs#7321 parent 805aa70 commit 95d063c
6 files changed
Lines changed: 201 additions & 199 deletions
File tree
- packages/solid/store
- src
- test
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
12 | | - | |
13 | | - | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
14 | 15 | | |
15 | 16 | | |
16 | | - | |
| 17 | + | |
| 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 | | |
| |||
146 | 134 | | |
147 | 135 | | |
148 | 136 | | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
149 | 143 | | |
150 | 144 | | |
151 | | - | |
152 | | - | |
153 | | - | |
154 | | - | |
155 | | - | |
156 | | - | |
157 | | - | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
158 | 150 | | |
159 | 151 | | |
160 | 152 | | |
| 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 | | |
0 commit comments