Weird typescript error in a monorepo (pnpm with turborepo)

Argument of type 'PgTableWithColumns<{ name: "users"; schema: undefined; columns: { id: PgColumn<{ name: string; tableName: "users"; dataType: "string"; columnType: "PgUUID"; data: string; driverParam: string; notNull: true; hasDefault: true; ... 6 more ...; generated: undefined; }, {}, {}>; ... 8 more ...; accessCodeSentTo: PgColumn...' is not assignable to parameter of type 'SQL<unknown> | Subquery<string, Record<string, unknown>> | PgViewBase<string, boolean, ColumnsSelection> | PgTable<TableConfig>'. Type 'PgTableWithColumns<{ name: "users"; schema: undefined; columns: { id: PgColumn<{ name: string; tableName: "users"; dataType: "string"; columnType: "PgUUID"; data: string; driverParam: string; notNull: true; hasDefault: true; ... 6 more ...; generated: undefined; }, {}, {}>; ... 8 more ...; accessCodeSentTo: PgColumn...' is not assignable to type 'PgTable<TableConfig>'. The types of '.config.columns' are incompatible between these types. Type '{ id: PgColumn<{ name: string; tableName: "users"; dataType: "string"; columnType: "PgUUID"; data: string; driverParam: string; notNull: true; hasDefault: true; isPrimaryKey: true; isAutoincrement: false; ... 4 more ...; generated: undefined; }, {}, {}>; ... 8 more ...; accessCodeSentTo: PgColumn<...>; }' is not assignable to type 'Record<string, PgColumn<ColumnBaseConfig<ColumnDataType, string>, {}, {}>>'. Property 'id' is incompatible with index signature. Type 'PgColumn<{ name: string; tableName: "users"; dataType: "string"; columnType: "PgUUID"; data: string; driverParam: string; notNull: true; hasDefault: true; isPrimaryKey: true; isAutoincrement: false; hasRuntimeDefault: false; enumValues: undefined; baseColumn: never; identity: undefined; generated: undefined; }, {}, ...' is not assignable to type 'PgColumn<ColumnBaseConfig<ColumnDataType, string>, {}, {}>'. The types of 'table..config.columns' are incompatible between these types. I cut here cuz max length of discord
1 Reply
Gary, el Pingüino Artefacto
This is the code:
db.select({
id: sql`${users.id}`.mapWith(UserId),
givenName: users.givenName,
accessCodeSentAt: users.accessCodeSentAt,
hasSentAccessAMinuteAgo: sql<boolean>`now() < (${users.accessCodeSentAt} + interval '1 minutes')`,
timeLeftInSeconds: sql<number>`extract(epoch from (now() - (${users.accessCodeSentAt} + interval '1 minutes')))`,
})
.from(userEmails)
// Error occurs here (on users)
.innerJoin(users, eq(users.id, userEmails.userId))
.where(eq(userEmails.email, user.email))
.limit(1)
db.select({
id: sql`${users.id}`.mapWith(UserId),
givenName: users.givenName,
accessCodeSentAt: users.accessCodeSentAt,
hasSentAccessAMinuteAgo: sql<boolean>`now() < (${users.accessCodeSentAt} + interval '1 minutes')`,
timeLeftInSeconds: sql<number>`extract(epoch from (now() - (${users.accessCodeSentAt} + interval '1 minutes')))`,
})
.from(userEmails)
// Error occurs here (on users)
.innerJoin(users, eq(users.id, userEmails.userId))
.where(eq(userEmails.email, user.email))
.limit(1)

Did you find this page helpful?