punn
punn•2y ago

Type API does not satisfy the constraint GenericAPI

I'm facing this error while running convex dev
Found 8 errors in the same file, starting at: convex/_generated/server.d.ts:49

TypeScript typecheck via `tsc` failed.
To ignore failing typecheck, use `--typecheck=disable`.
Preparing Convex functions...
convex/_generated/server.d.ts:49:47 - error TS2344: Type 'API' does not satisfy the constraint 'GenericAPI'.
Types of property 'publicQueries' are incompatible.
Type '{ readonly "users:getUser": () => { _id: Id<"users">; _creationTime: number; number?: string | undefined; email?: string | undefined; stripeCustomerId?: string | undefined; name: string; hasEmail: boolean; hasNumber: boolean; tokenIdentifier: string; finishedProfileSetup: boolean; } | null; ... 20 more ...; "integra...' is not assignable to type 'Record<string, ConvexFunction>'.
Property '"integrationsStore/dist/hostaway:storeRawReservations"' is incompatible with index signature.
Type '(...args: [] | [args: any]) => any' is not assignable to type 'ConvexFunction'.
Types of parameters 'args' and 'args' are incompatible.
Type '[args?: any]' is not assignable to type '[] | [args: any]'.
Type '[args?: any]' is not assignable to type '[args: any]'.
Source provides no match for required element at position 0 in target.
Found 8 errors in the same file, starting at: convex/_generated/server.d.ts:49

TypeScript typecheck via `tsc` failed.
To ignore failing typecheck, use `--typecheck=disable`.
Preparing Convex functions...
convex/_generated/server.d.ts:49:47 - error TS2344: Type 'API' does not satisfy the constraint 'GenericAPI'.
Types of property 'publicQueries' are incompatible.
Type '{ readonly "users:getUser": () => { _id: Id<"users">; _creationTime: number; number?: string | undefined; email?: string | undefined; stripeCustomerId?: string | undefined; name: string; hasEmail: boolean; hasNumber: boolean; tokenIdentifier: string; finishedProfileSetup: boolean; } | null; ... 20 more ...; "integra...' is not assignable to type 'Record<string, ConvexFunction>'.
Property '"integrationsStore/dist/hostaway:storeRawReservations"' is incompatible with index signature.
Type '(...args: [] | [args: any]) => any' is not assignable to type 'ConvexFunction'.
Types of parameters 'args' and 'args' are incompatible.
Type '[args?: any]' is not assignable to type '[] | [args: any]'.
Type '[args?: any]' is not assignable to type '[args: any]'.
Source provides no match for required element at position 0 in target.
Those functions mentioned in the error message was working as intended until I added more actions and mutations. My suspicion is the :any typing but not sure why this is the case. I need to use :any as I'm working with large response objects from an external API call.
7 Replies
punn
punnOP•2y ago
Happy to share repo privately 🙂
ian
ian•2y ago
Is this after upgrading to Convex 0.13.0? If so, it might need a npx convex codegen (or npx convex dev to be restarted using the 0.13.0 version). We switched from positional arguments, so ...args looks suspicious. What does the hostaway:storeRawReservations function signature look like?
punn
punnOP•2y ago
I think i fixed the issue by removing the generated dist not sure why it was generated for the following file convex > helper_folder > file.ts
ian
ian•2y ago
It naively adds types for all the files, but tries to only infer convex functions that have the convex function signature. What was the function’s signature out of curiosity? Would be interesting to figure out what went wrong in case it affects others. hmu on DM if you’re open to sharing privately
punn
punnOP•2y ago
This is the function in question
No description
punn
punnOP•2y ago
note: the error only occurred after I added a few other functions with similar any params and was working fine before I had encountered something similar a while ago where the error arises after some threshold number of untyped params/functions
ian
ian•2y ago
Interesting. Sounds like the Typescript checker is getting overwhelmed. If you find any good workarounds (other than avoiding any, which sounds like it helped), lmk. Others here have deeper TypeScript expertise, maybe they'll have ideas too.

Did you find this page helpful?