openapi-typescript icon indicating copy to clipboard operation
openapi-typescript copied to clipboard

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

Open vovsemenv opened this issue 1 year ago • 6 comments

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

vovsemenv avatar Aug 28 '24 21:08 vovsemenv