Aggregates - TS2589: Type instantiation is excessively deep and possibly infinite.

I am getting the error when defining bounds for aggregates.

export const incomingAggregate = new TableAggregate<{
  Namespace: Id<"users"> | Id<"organization">; // album name
  Key: number; // creation time
  DataModel: DataModel;
  TableName: "incoming";
}>(components.incomingAggregate, {
  namespace: (doc) => doc.owner,
  sortKey: (doc) => doc._creationTime,
});


export const countByOwnerAndMonth = query({
  args: {
    org: v.optional(v.string()),
    month: v.optional(v.string()),
  },
  handler: async (ctx, args) => {
    const owner = await ensureOwner(ctx, args.org);

    const start = dayjs(args.month).startOf("month").unix() * 1000;
    const end = dayjs(args.month).endOf("month").unix() * 1000;

    return await incomingAggregate.count(ctx, {
      namespace: owner,
      bounds: {
        lower: { key: start, inclusive: true },
        upper: { key: end, inclusive: true },
      },
    });
  },
});


there is a way to workaround by casting the bounds ie to "unknown"
image.png
image.png
Was this page helpful?