Abdul
Abdul5w ago

Type instantiation is excessively deep and possibly infinite.

I’m encountering the following TypeScript error in my project: Type instantiation is excessively deep and possibly infinite I’m new to TypeScript and don’t have much experience with its type system. My project has a complex directory structure with multiple levels of nesting, and I suspect the deeply nested structure might be causing the issue. Here is how directory structure roughly looks like:
project-root
├── generated
│ ├── api.d.ts
│ ├── api.js
│ ├── dataModel.d.ts
│ ├── server.d.ts
│ └── server.js
├── core
│ ├── index.ts
│ ├── utilities.ts
│ └── types.ts
├── modules
│ ├── featureA
│ │ ├── helpers.ts
│ │ ├── logic.ts
│ │ ├── types.ts
│ │ └── subFeature
│ │ ├── core.ts
│ │ ├── subLogic.ts
│ │ └── subTypes.ts
│ ├── featureB
│ │ ├── handlers.ts
│ │ ├── queries.ts
│ │ └── types.ts
│ └── shared
│ ├── auth.ts
│ ├── config.ts
│ └── utils.ts
├── queries
│ ├── featureAQueries.ts
│ ├── featureBQueries.ts
│ └── sharedQueries.ts
├── schema
│ ├── entities
│ │ ├── entityA.ts
│ │ ├── entityB.ts
│ │ └── entityC.ts
│ ├── relations.ts
│ └── types.ts
└── webhooks
└── eventHandlers.ts
project-root
├── generated
│ ├── api.d.ts
│ ├── api.js
│ ├── dataModel.d.ts
│ ├── server.d.ts
│ └── server.js
├── core
│ ├── index.ts
│ ├── utilities.ts
│ └── types.ts
├── modules
│ ├── featureA
│ │ ├── helpers.ts
│ │ ├── logic.ts
│ │ ├── types.ts
│ │ └── subFeature
│ │ ├── core.ts
│ │ ├── subLogic.ts
│ │ └── subTypes.ts
│ ├── featureB
│ │ ├── handlers.ts
│ │ ├── queries.ts
│ │ └── types.ts
│ └── shared
│ ├── auth.ts
│ ├── config.ts
│ └── utils.ts
├── queries
│ ├── featureAQueries.ts
│ ├── featureBQueries.ts
│ └── sharedQueries.ts
├── schema
│ ├── entities
│ │ ├── entityA.ts
│ │ ├── entityB.ts
│ │ └── entityC.ts
│ ├── relations.ts
│ └── types.ts
└── webhooks
└── eventHandlers.ts
Are there general best practices for handling query and mutation definitions in a project with this kind of nested structure?
2 Replies
Convex Bot
Convex Bot5w ago
Thanks for posting in <#1088161997662724167>. Reminder: If you have a Convex Pro account, use the Convex Dashboard to file support tickets. - Provide context: What are you trying to achieve, what is the end-user interaction, what are you seeing? (full error message, command output, etc.) - Use search.convex.dev to search Docs, Stack, and Discord all at once. - Additionally, you can post your questions in the Convex Community's <#1228095053885476985> channel to receive a response from AI. - Avoid tagging staff unless specifically instructed. Thank you!
erquhart
erquhart5w ago
Your directory structure looks fine, this is usually due to some function running ctx.runQuery/Mutation/Action and then returning a value received from that query/mutation/action that was triggered. There's info in the docs for this here: https://docs.convex.dev/functions/actions#dealing-with-circular-type-inference
Actions | Convex Developer Hub
Actions can call third party services to do things such as processing a payment

Did you find this page helpful?