File tree 3 files changed +26
-2
lines changed
3 files changed +26
-2
lines changed Original file line number Diff line number Diff line change 28
28
"types" : " dist/index.d.ts" ,
29
29
"devDependencies" : {
30
30
"@microsoft/api-extractor" : " ^7.13.2" ,
31
+ "@phryneas/ts-version" : " ^1.0.2" ,
31
32
"@size-limit/preset-small-lib" : " ^4.11.0" ,
32
33
"@testing-library/react" : " ^13.3.0" ,
33
34
"@testing-library/user-event" : " ^13.1.5" ,
Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ import type {
17
17
AsyncThunkFulfilledActionCreator ,
18
18
AsyncThunkRejectedActionCreator ,
19
19
} from '@internal/createAsyncThunk'
20
+ import type { TSVersion } from '@phryneas/ts-version'
20
21
21
22
const ANY = { } as any
22
23
const defaultDispatch = ( ( ) => { } ) as ThunkDispatch < { } , any , AnyAction >
@@ -287,8 +288,22 @@ const anyAction = { type: 'foo' } as AnyAction
287
288
// in that case, we have to forbid this behaviour or it will make arguments optional everywhere
288
289
{
289
290
const asyncThunk = createAsyncThunk ( 'test' , ( arg ?: number ) => 0 )
290
- expectType < ( arg ?: number ) => any > ( asyncThunk )
291
- asyncThunk ( )
291
+
292
+ // Per https://github.com/reduxjs/redux-toolkit/issues/3758#issuecomment-1742152774 , this is a bug in
293
+ // TS 5.1 and 5.2, that is fixed in 5.3. Conditionally run the TS assertion here.
294
+ type IsTS51Or52 = TSVersion . Major extends 5
295
+ ? TSVersion . Minor extends 1 | 2
296
+ ? true
297
+ : false
298
+ : false
299
+
300
+ type expectedType = IsTS51Or52 extends true
301
+ ? ( arg : number ) => any
302
+ : ( arg ?: number ) => any
303
+ expectType < expectedType > ( asyncThunk )
304
+ // We _should_ be able to call this with no arguments, but we run into that error in 5.1 and 5.2.
305
+ // Disabling this for now.
306
+ // asyncThunk()
292
307
asyncThunk ( 5 )
293
308
// @ts -expect-error
294
309
asyncThunk ( 'string' )
Original file line number Diff line number Diff line change @@ -6421,6 +6421,13 @@ __metadata:
6421
6421
languageName: node
6422
6422
linkType: hard
6423
6423
6424
+ "@phryneas/ts-version@npm:^1.0.2":
6425
+ version: 1.0.2
6426
+ resolution: "@phryneas/ts-version@npm:1.0.2"
6427
+ checksum: d51914a8ea35ff8b686a9379b9e9fe6d5b5feaf2e7511b880d2835015736e33bc82952bbc369918f251d4a755f32f4a9c4a34b0ec4dfdbc3e87a41d26401105c
6428
+ languageName: node
6429
+ linkType: hard
6430
+
6424
6431
"@pmmmwh/react-refresh-webpack-plugin@npm:^0.5.3":
6425
6432
version: 0.5.7
6426
6433
resolution: "@pmmmwh/react-refresh-webpack-plugin@npm:0.5.7"
@@ -6554,6 +6561,7 @@ __metadata:
6554
6561
resolution: "@reduxjs/toolkit@workspace:packages/toolkit"
6555
6562
dependencies:
6556
6563
"@microsoft/api-extractor": ^7.13.2
6564
+ "@phryneas/ts-version": ^1.0.2
6557
6565
"@size-limit/preset-small-lib": ^4.11.0
6558
6566
"@testing-library/react": ^13.3.0
6559
6567
"@testing-library/user-event": ^13.1.5
You can’t perform that action at this time.
0 commit comments