Skip to content

Commit e6acf40

Browse files
committed
Update buildHooks test and type expectations for useLazyQuery unwrapping
1 parent a704adc commit e6acf40

File tree

2 files changed

+18
-10
lines changed

2 files changed

+18
-10
lines changed

packages/toolkit/src/query/core/buildInitiate.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ Features like automatic cache collection, automatic refetching etc. will not be
356356
arg: thunkResult.arg,
357357
requestId,
358358
abort,
359-
unwrap: unwrap,
359+
unwrap,
360360
unsubscribe: reset,
361361
reset,
362362
})

packages/toolkit/src/query/tests/buildHooks.test.tsx

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -791,16 +791,24 @@ describe('hooks tests', () => {
791791

792792
// no-op simply for clearer type assertions
793793
res.then((result) => {
794-
expectExactType<
795-
| {
796-
error: { status: number; data: unknown } | SerializedError
794+
if (result.isSuccess) {
795+
expectType<{
796+
data: {
797+
name: string
797798
}
798-
| {
799-
data: {
800-
name: string
801-
}
802-
}
803-
>(result)
799+
}>(result)
800+
}
801+
if (result.isError) {
802+
expectType<{
803+
error: { status: number; data: unknown } | SerializedError
804+
}>(result)
805+
}
806+
})
807+
808+
res.unwrap().then((result) => {
809+
expectType<{
810+
name: string
811+
}>(result)
804812
})
805813

806814
expectType<number>(res.arg)

0 commit comments

Comments
 (0)