sajS
Convex Community6mo ago
3 replies
saj

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,
    };
  })
);


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">, });


the error persists.
Was this page helpful?