qian321Q
Convex Community6mo ago
2 replies
qian321

Can't find a way to address error: Type instantiation is excessively deep and possibly infinite.

I've tried all suggestions discussed already in discord but none seems to work for me, add return types, comment out all my logic, change ts target to ESNext, etc. everything. I'm still facing this error when using the api calls.
One workaround I found is I can do something like:
import { api as convexApi } from "@stilltime/backend/api";
...
// Type utility to simplify deep types
type Simplify<T> = { [K in keyof T]: T[K] } & {};

// Create a simplified version of the API to avoid deep type instantiation
// @ts-ignore TS2589: Type instantiation is excessively deep and possibly infinite
const api = convexApi as Simplify<typeof convexApi>;

and then just use this wrapped api instead. This way I persist type check while only need to add one ts-ignore.

My question is, is this an okay solution? will there be other gotchas?
Was this page helpful?