Skip to content

Commit 0b961e2

Browse files
EskiMojo14markerikson
authored andcommitted
add argSchema inference test
1 parent 4048cda commit 0b961e2

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

packages/toolkit/src/query/tests/createApi.test-d.ts

+15
Original file line numberDiff line numberDiff line change
@@ -474,13 +474,28 @@ describe('type tests', () => {
474474
query: ({ id }: { id: number }) => `/post/${id}`,
475475
responseSchema: postSchema,
476476
}),
477+
query2: build.query({
478+
query: (arg) => {
479+
expectTypeOf(arg).toEqualTypeOf<{ id: number }>()
480+
return `/post/${arg.id}`
481+
},
482+
argSchema,
483+
responseSchema: postSchema,
484+
}),
477485
}),
478486
})
479487

480488
expectTypeOf(api.endpoints.query.Types.QueryArg).toEqualTypeOf<{
481489
id: number
482490
}>()
483491
expectTypeOf(api.endpoints.query.Types.ResultType).toEqualTypeOf<Post>()
492+
493+
expectTypeOf(api.endpoints.query2.Types.QueryArg).toEqualTypeOf<{
494+
id: number
495+
}>()
496+
expectTypeOf(
497+
api.endpoints.query2.Types.ResultType,
498+
).toEqualTypeOf<Post>()
484499
})
485500
})
486501
})

0 commit comments

Comments
 (0)