Commit 6753973
committed
change default ThunkArg of cAT to OptionalUnknown
Since TypeScript 4.0, the following example will cause an error when checking JavaScript files (with allowJs & checkJs):
```js
const thunk = createAsyncThunk('', arg => {})
thunk()
// @ts-expect-error Expected 0 arguments, but got 1.ts(2554)
thunk('something')
```
The only way around that without breaking too much explicit existing behaviour is this type "OptionalUnknown".
On the flip side, using a payloadcreator without a defined argument, like
```ts
const thunk = createAsyncThunk('', () => {})
```
will now generate a thunk that can optionally be called with any first argument opposed to a thunk that would not accept any argument before.1 parent 6093e0c commit 6753973
File tree
3 files changed
+27
-4
lines changed- etc
- src
- type-tests/files
3 files changed
+27
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
129 | 129 | | |
130 | 130 | | |
131 | 131 | | |
132 | | - | |
| 132 | + | |
133 | 133 | | |
134 | 134 | | |
135 | 135 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
173 | 173 | | |
174 | 174 | | |
175 | 175 | | |
| 176 | + | |
| 177 | + | |
176 | 178 | | |
177 | 179 | | |
178 | 180 | | |
| |||
270 | 272 | | |
271 | 273 | | |
272 | 274 | | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
273 | 296 | | |
274 | | - | |
275 | 297 | | |
276 | 298 | | |
277 | 299 | | |
| |||
280 | 302 | | |
281 | 303 | | |
282 | 304 | | |
283 | | - | |
| 305 | + | |
284 | 306 | | |
285 | 307 | | |
286 | 308 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
213 | 213 | | |
214 | 214 | | |
215 | 215 | | |
216 | | - | |
| 216 | + | |
| 217 | + | |
217 | 218 | | |
218 | 219 | | |
219 | 220 | | |
| |||
0 commit comments