Skip to content

#1580 causes type issue in MaybeOptionalInit #1584

Closed
@mikestopcontinues

Description

@mikestopcontinues

MaybeOptionalInit now requires Paths[P] to be a complete record including every HttpMethod. However, routes rarely have every method. I think it should be defined as Partial<Record<HttpMethod, {}>> instead. The same with ClientMethod:

export type MaybeOptionalInit<
  P extends Partial<Record<HttpMethod, {}>>,
  M extends keyof P,
> =
  HasRequiredKeys<FetchOptions<FilterKeys<P, M>>> extends never
    ? [(FetchOptions<FilterKeys<P, M>> | undefined)?]
    : [FetchOptions<FilterKeys<P, M>>];

export type ClientMethod<
  Paths extends Record<string, Partial<Record<HttpMethod, {}>>>,
  M extends HttpMethod,
> = <
  P extends PathsWithMethod<Paths, M>,
  I extends MaybeOptionalInit<Paths[P], M>,
>(
  url: P,
  ...init: I
) => Promise<FetchResponse<Paths[P][M], I[0]>>;

Metadata

Metadata

Assignees

No one assigned

    Labels

    PRs welcomePRs are welcome to solve this issue!bugSomething isn't workinggood first issueStraightforward problem, solvable for first-time contributors without deep knowledge of the projectopenapi-fetchRelevant to the openapi-fetch library

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions