nested select type issue

hello there...
this code returns desired restuls but i have type issues
await db
    .select({
      ...getTableColumns(productTable),
      variant: {
        ...getTableColumns(variantTable),
        size: getTableColumns(sizeTable),
        color: getTableColumns(colorTable),
      },
      brand: getTableColumns(brandTable),
      category: getTableColumns(categoryTable),
    })
    .from(productTable)
    .where(eq(productTable.id, +id))
    .leftJoin(
      variantTable,
      eq(variantTable.product_id, productTable.id),
    )
    .leftJoin(brandTable, eq(brandTable.id, productTable.brand_id))
    .leftJoin(
      categoryTable,
      eq(categoryTable.id, productTable.category_id),
    )
    .leftJoin(colorTable, eq(colorTable.id, variantTable.color_id))
    .leftJoin(sizeTable, eq(sizeTable.id, variantTable.size_id));

error
Type '{ id: PgColumn<{ name: "id"; tableName: "sizes"; dataType: "number"; columnType: "PgSerial"; data: number; driverParam: number; notNull: true; hasDefault: true; isPrimaryKey: true; isAutoincrement: false; ... 4 more ...; generated: undefined; }, {}, {}>; name: PgColumn<...>; store_id: PgColumn<...>; }' is not assignable to type 'SQL<unknown> | Aliased<unknown> | PgColumn<ColumnBaseConfig<ColumnDataType, string>, {}, {}>'.
  Type '{ id: PgColumn<{ name: "id"; tableName: "sizes"; dataType: "number"; columnType: "PgSerial"; data: number; driverParam: number; notNull: true; hasDefault: true; isPrimaryKey: true; isAutoincrement: false; ... 4 more ...; generated: undefined; }, {}, {}>; name: PgColumn<...>; store_id: PgColumn<...>; }' is missing the following properties from type 'PgColumn<ColumnBaseConfig<ColumnDataType, string>, {}, {}>': table, _, keyAsName, primary, and 18 more.ts(2322)
Was this page helpful?