Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

react query plugin not playing well with client-fetch options #1256

Open
nutrian opened this issue Nov 8, 2024 · 2 comments
Open

react query plugin not playing well with client-fetch options #1256

nutrian opened this issue Nov 8, 2024 · 2 comments
Labels
bug 🔥 Something isn't working info needed ❓ Further information is required

Comments

@nutrian
Copy link

nutrian commented Nov 8, 2024

Description

Lots of type errors in the generated react-query.gen.ts

import type { Options } from '@hey-api/client-fetch';

type QueryKey<TOptions extends Options> = [
    Pick<TOptions, 'baseUrl' | 'body' | 'headers' | 'path' | 'query'> & {
        _id: string;
        _infinite?: boolean;
    }
];
type OptionsBase<ThrowOnError extends boolean> = Omit<RequestOptionsBase<ThrowOnError>, 'url'> & {
    /**
     * You can provide a client instance returned by `createClient()` instead of
     * individual options. This might be also useful if you want to implement a
     * custom client.
     */
    client?: Client;
};
type Options<T = unknown, ThrowOnError extends boolean = boolean> = T extends {
    body?: any;
} ? T extends {
    headers?: any;
} ? OmitKeys<OptionsBase<ThrowOnError>, 'body' | 'headers'> & T : OmitKeys<OptionsBase<ThrowOnError>, 'body'> & T & Pick<OptionsBase<ThrowOnError>, 'headers'> : T extends {
    headers?: any;
} ? OmitKeys<OptionsBase<ThrowOnError>, 'headers'> & T & Pick<OptionsBase<ThrowOnError>, 'body'> : OptionsBase<ThrowOnError> & T;

Resulting errors

Type 'string' does not satisfy the constraint 'keyof TOptions'.
  Type 'string' is not assignable to type 'keyof TOptions'.
    Type '"body"' is not assignable to type '"method" | "cache" | "credentials" | "integrity" | "keepalive" | "mode" | "priority" | "redirect" | "referrer" | "referrerPolicy" | "signal" | "window" | "path" | "query" | "baseUrl" | ... 6 more ... | "client"'.ts(2344)

Reproducible example or configuration

Can't reproduce the error on stackblitz, no idea why.... tried aligning typescript and hey-api package versions on stackblitz as my local machine, just works on stackblitz for some reason

node 18.16.1
typescript 5.4.5
@hey-api/client-fetch 0.4.2
@hey-api/openapi-ts 0.54.0

OpenAPI specification (optional)

No response

System information (optional)

No response

@nutrian nutrian added the bug 🔥 Something isn't working label Nov 8, 2024
@mrlubos
Copy link
Member

mrlubos commented Nov 8, 2024

@nutrian can you provide versions of all relevant packages?

@nutrian
Copy link
Author

nutrian commented Nov 8, 2024

node 18.16.1
typescript 5.4.5
@hey-api/client-fetch 0.4.2
@hey-api/openapi-ts 0.54.0

@mrlubos mrlubos added the info needed ❓ Further information is required label Nov 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🔥 Something isn't working info needed ❓ Further information is required
Projects
None yet
Development

No branches or pull requests

2 participants