这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/flat-turkeys-laugh.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@hey-api/openapi-ts": patch
---

**@tanstack/query**: add type annotations to `queryOptions()`
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,19 @@ import type {
DeletePetData,
DeleteUserData,
FindPetsByStatusData,
FindPetsByStatusResponse,
FindPetsByTagsData,
FindPetsByTagsResponse,
GetInventoryData,
GetInventoryResponse,
GetOrderByIdData,
GetOrderByIdResponse,
GetPetByIdData,
GetPetByIdResponse,
GetUserByNameData,
GetUserByNameResponse,
LoginUserData,
LoginUserResponse,
LogoutUserData,
PlaceOrderData,
PlaceOrderResponse,
Expand Down Expand Up @@ -160,7 +167,12 @@ export const findPetsByStatusQueryKey = (
export const findPetsByStatusOptions = (
options: Options<FindPetsByStatusData>,
) =>
queryOptions({
queryOptions<
FindPetsByStatusResponse,
DefaultError,
FindPetsByStatusResponse,
ReturnType<typeof findPetsByStatusQueryKey>
>({
queryFn: async ({ queryKey, signal }) => {
const { data } = await findPetsByStatus({
...options,
Expand All @@ -182,7 +194,12 @@ export const findPetsByTagsQueryKey = (options: Options<FindPetsByTagsData>) =>
* Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
*/
export const findPetsByTagsOptions = (options: Options<FindPetsByTagsData>) =>
queryOptions({
queryOptions<
FindPetsByTagsResponse,
DefaultError,
FindPetsByTagsResponse,
ReturnType<typeof findPetsByTagsQueryKey>
>({
queryFn: async ({ queryKey, signal }) => {
const { data } = await findPetsByTags({
...options,
Expand Down Expand Up @@ -229,7 +246,12 @@ export const getPetByIdQueryKey = (options: Options<GetPetByIdData>) =>
* Returns a single pet.
*/
export const getPetByIdOptions = (options: Options<GetPetByIdData>) =>
queryOptions({
queryOptions<
GetPetByIdResponse,
DefaultError,
GetPetByIdResponse,
ReturnType<typeof getPetByIdQueryKey>
>({
queryFn: async ({ queryKey, signal }) => {
const { data } = await getPetById({
...options,
Expand Down Expand Up @@ -309,7 +331,12 @@ export const getInventoryQueryKey = (options?: Options<GetInventoryData>) =>
* Returns a map of status codes to quantities.
*/
export const getInventoryOptions = (options?: Options<GetInventoryData>) =>
queryOptions({
queryOptions<
GetInventoryResponse,
DefaultError,
GetInventoryResponse,
ReturnType<typeof getInventoryQueryKey>
>({
queryFn: async ({ queryKey, signal }) => {
const { data } = await getInventory({
...options,
Expand Down Expand Up @@ -385,7 +412,12 @@ export const getOrderByIdQueryKey = (options: Options<GetOrderByIdData>) =>
* For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions.
*/
export const getOrderByIdOptions = (options: Options<GetOrderByIdData>) =>
queryOptions({
queryOptions<
GetOrderByIdResponse,
DefaultError,
GetOrderByIdResponse,
ReturnType<typeof getOrderByIdQueryKey>
>({
queryFn: async ({ queryKey, signal }) => {
const { data } = await getOrderById({
...options,
Expand Down Expand Up @@ -465,7 +497,12 @@ export const loginUserQueryKey = (options?: Options<LoginUserData>) =>
* Log into the system.
*/
export const loginUserOptions = (options?: Options<LoginUserData>) =>
queryOptions({
queryOptions<
LoginUserResponse,
DefaultError,
LoginUserResponse,
ReturnType<typeof loginUserQueryKey>
>({
queryFn: async ({ queryKey, signal }) => {
const { data } = await loginUser({
...options,
Expand All @@ -487,7 +524,12 @@ export const logoutUserQueryKey = (options?: Options<LogoutUserData>) =>
* Log user out of the system.
*/
export const logoutUserOptions = (options?: Options<LogoutUserData>) =>
queryOptions({
queryOptions<
unknown,
DefaultError,
unknown,
ReturnType<typeof logoutUserQueryKey>
>({
queryFn: async ({ queryKey, signal }) => {
const { data } = await logoutUser({
...options,
Expand Down Expand Up @@ -534,7 +576,12 @@ export const getUserByNameQueryKey = (options: Options<GetUserByNameData>) =>
* Get user detail based on username.
*/
export const getUserByNameOptions = (options: Options<GetUserByNameData>) =>
queryOptions({
queryOptions<
GetUserByNameResponse,
DefaultError,
GetUserByNameResponse,
ReturnType<typeof getUserByNameQueryKey>
>({
queryFn: async ({ queryKey, signal }) => {
const { data } = await getUserByName({
...options,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,19 @@ import type {
DeletePetData,
DeleteUserData,
FindPetsByStatusData,
FindPetsByStatusResponse,
FindPetsByTagsData,
FindPetsByTagsResponse,
GetInventoryData,
GetInventoryResponse,
GetOrderByIdData,
GetOrderByIdResponse,
GetPetByIdData,
GetPetByIdResponse,
GetUserByNameData,
GetUserByNameResponse,
LoginUserData,
LoginUserResponse,
LogoutUserData,
PlaceOrderData,
PlaceOrderResponse,
Expand Down Expand Up @@ -143,7 +150,12 @@ export const findPetsByStatusQueryKey = (
export const findPetsByStatusOptions = (
options: Options<FindPetsByStatusData>,
) =>
queryOptions({
queryOptions<
FindPetsByStatusResponse,
DefaultError,
FindPetsByStatusResponse,
ReturnType<typeof findPetsByStatusQueryKey>
>({
queryFn: async ({ queryKey, signal }) => {
const { data } = await Sdk.__registry.get().findPetsByStatus({
...options,
Expand All @@ -165,7 +177,12 @@ export const findPetsByTagsQueryKey = (options: Options<FindPetsByTagsData>) =>
* Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
*/
export const findPetsByTagsOptions = (options: Options<FindPetsByTagsData>) =>
queryOptions({
queryOptions<
FindPetsByTagsResponse,
DefaultError,
FindPetsByTagsResponse,
ReturnType<typeof findPetsByTagsQueryKey>
>({
queryFn: async ({ queryKey, signal }) => {
const { data } = await Sdk.__registry.get().findPetsByTags({
...options,
Expand Down Expand Up @@ -212,7 +229,12 @@ export const getPetByIdQueryKey = (options: Options<GetPetByIdData>) =>
* Returns a single pet.
*/
export const getPetByIdOptions = (options: Options<GetPetByIdData>) =>
queryOptions({
queryOptions<
GetPetByIdResponse,
DefaultError,
GetPetByIdResponse,
ReturnType<typeof getPetByIdQueryKey>
>({
queryFn: async ({ queryKey, signal }) => {
const { data } = await Sdk.__registry.get().getPetById({
...options,
Expand Down Expand Up @@ -292,7 +314,12 @@ export const getInventoryQueryKey = (options?: Options<GetInventoryData>) =>
* Returns a map of status codes to quantities.
*/
export const getInventoryOptions = (options?: Options<GetInventoryData>) =>
queryOptions({
queryOptions<
GetInventoryResponse,
DefaultError,
GetInventoryResponse,
ReturnType<typeof getInventoryQueryKey>
>({
queryFn: async ({ queryKey, signal }) => {
const { data } = await Sdk.__registry.get().getInventory({
...options,
Expand Down Expand Up @@ -368,7 +395,12 @@ export const getOrderByIdQueryKey = (options: Options<GetOrderByIdData>) =>
* For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions.
*/
export const getOrderByIdOptions = (options: Options<GetOrderByIdData>) =>
queryOptions({
queryOptions<
GetOrderByIdResponse,
DefaultError,
GetOrderByIdResponse,
ReturnType<typeof getOrderByIdQueryKey>
>({
queryFn: async ({ queryKey, signal }) => {
const { data } = await Sdk.__registry.get().getOrderById({
...options,
Expand Down Expand Up @@ -448,7 +480,12 @@ export const loginUserQueryKey = (options?: Options<LoginUserData>) =>
* Log into the system.
*/
export const loginUserOptions = (options?: Options<LoginUserData>) =>
queryOptions({
queryOptions<
LoginUserResponse,
DefaultError,
LoginUserResponse,
ReturnType<typeof loginUserQueryKey>
>({
queryFn: async ({ queryKey, signal }) => {
const { data } = await Sdk.__registry.get().loginUser({
...options,
Expand All @@ -470,7 +507,12 @@ export const logoutUserQueryKey = (options?: Options<LogoutUserData>) =>
* Log user out of the system.
*/
export const logoutUserOptions = (options?: Options<LogoutUserData>) =>
queryOptions({
queryOptions<
unknown,
DefaultError,
unknown,
ReturnType<typeof logoutUserQueryKey>
>({
queryFn: async ({ queryKey, signal }) => {
const { data } = await Sdk.__registry.get().logoutUser({
...options,
Expand Down Expand Up @@ -517,7 +559,12 @@ export const getUserByNameQueryKey = (options: Options<GetUserByNameData>) =>
* Get user detail based on username.
*/
export const getUserByNameOptions = (options: Options<GetUserByNameData>) =>
queryOptions({
queryOptions<
GetUserByNameResponse,
DefaultError,
GetUserByNameResponse,
ReturnType<typeof getUserByNameQueryKey>
>({
queryFn: async ({ queryKey, signal }) => {
const { data } = await Sdk.__registry.get().getUserByName({
...options,
Expand Down
Loading
Loading