saj
saj•3w ago

zCustomQuery and use of zid + Id<"tableName" returns type errors: is incompatible with index

anyone able to help with this? using zCustomQuery causes issues when defining zid("tableName") in the validator. fyi: using convex ents, but that doesn't appear related. Argument of type '{ tableNameId: Id<"tableName">; }' is not assignable to parameter of type '{ [x: string]: undefined; tableNameId: string & { tableName: "tableName"; }; }'. Property 'tableNameId' is incompatible with index signature. Type 'Id<"tableName">' is not assignable to type 'undefined'.ts(2345) (property) tableNameId: string & { tableName: "tableName"; } here is the zInternalQuery.
export const zInternalQuery = zCustomQuery(
baseInternalQuery,
customCtx(async (ctx) => {
return {
table: entsTableFactory(ctx, entDefinitions),
db: undefined,
};
})
);
export const zInternalQuery = zCustomQuery(
baseInternalQuery,
customCtx(async (ctx) => {
return {
table: entsTableFactory(ctx, entDefinitions),
db: undefined,
};
})
);
if i convert it from zCustomQuery to customQuery and use v("tableName") everything works normally. when running the query (e.g. client side), the expected id is type cast, e.g.
const query = await ctx.runQuery(internal.router.file.function, { tableNameId: parsedBody.tableNameId as Id<"tableName">, });
const query = await ctx.runQuery(internal.router.file.function, { tableNameId: parsedBody.tableNameId as Id<"tableName">, });
the error persists.
3 Replies
Convex Bot
Convex Bot•3w 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!
saj
sajOP•3w ago
actually, i see the issue report on github, my bad 🙂 https://github.com/get-convex/convex-helpers/issues/708
GitHub
Getting types errors in v0.1.100 when calling a zCustomQuery with c...
TSC error: { userId: Id&lt;&quot;users&quot;&gt;; } is not assignable to parameter of type { [x: string]: undefined; userId: string &amp; { __tableName: &quot;users&quot;; }; } Reproduction: https:...
ian
ian•3w ago
Fixed and shipped in the latest release - sorry about that!

Did you find this page helpful?