Skip to content

openapi-fetch Type instantiation is excessively deep and possibly infinite. #1882

Open
@vovsemenv

Description

@vovsemenv

I have the code with 2 api calls - one with "openapi-fetch" other with "openapi-react-query"
but only "openapi-react-query" have actual error on paths that didn't exist,
"openapi-fetch"generates the Type instantiation is excessively deep and possibly infinite.

Because of that vscode autocomplete didn't work in case with "openapi-fetch"

import type { paths } from "app/typings/__generated/api";

import createFetchClient from "openapi-fetch";
import createClient from "openapi-react-query";

export const fetchClient = createFetchClient<paths>({});
export const $api = createClient(fetchClient);

fetchClient.GET("/api/d");
// ^ Type instantiation is excessively deep and possibly infinite.
$api.useQuery("get", "/api/sdf");
// ^ Argument of type '"/api/sdf"' is not assignable to parameter of type 'PathsWithMethod<paths, "get">'

fetchClient.GET("/api/accessgroup");
// ^ Existing url works fine
$api.useQuery("get", "/api/accessgroup");
// ^ Existing url works fine

api.d.ts.zip

Metadata

Metadata

Assignees

Labels

PRs welcomePRs are welcome to solve this issue!enhancementNew feature or requestgood first issueStraightforward problem, solvable for first-time contributors without deep knowledge of the projectopenapi-fetchRelevant to the openapi-fetch library

Type

No type

Projects

Status

Accepted

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions