TS2589: Type instantiation is excessively deep and possibly infinite.
Getting this when calling
internal
and api
like here
What can I do?
7 Replies
Actions | Convex Developer Hub
Actions can call third party services to do things such as processing a payment
It's a different issue, this is about type complexity and I dont get it on the return value, that's actually correct, i get it on the internal or api import itself
would me typing out the returns validator on each function fix this?
It's still likely the same issue, shows up in different places. I've seen this happen across all my convex function references in some situations, due to one
ctx.runQuery()
. Look at your recently touched usages of ctx.runQuery/Mutation/Action
to figure out where it's happening.Ok ill look into where i mightve called them
That didnt fix it, i typed out all my run calls ( not a lot btw ) and typed out the returns of every function in my model directory
Here is an example
every function in my project is like this, every call to ctx.run_ whose returns is used
is explicitly typed, and yet, when using
internal
or api
i get the type instantiation errorYour handler return type annotations can't utilize Convex generated types, otherwise you're back in the same boat. Do
ParkingLot
, Booking
, and/or Payment
use types that utilize schema or anything from convex/_generated?Yes they utilize Doc
I can remove that dependency, not ideal though
It's often easier to pinpoint something closer to the actual runQuery/Mutation/Action. Like, maybe after you run the query, you're just returning a small subset of the received value, so you just type those statically in place. That's what I'm doing in all such instances currently. May or may not help in your situation, depending on usage.
Ah your last example is doing inline, just noticed that
yeah, so for example if you're just getting ongoing bookings to check for conflicts, maybe hasConflict only needs one or two properties from each booking document, I think just typing that subset works
Taking a minimal typing approach in general is often helpful. Eg., a function that only uses one or two props that are present in a document can just rely on an object with those types rather than requiring the entire object to be satisfied.