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
5 Replies
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)
Baron Von Enablestein
Did you ever find a fix? I am getting the same error on an innerJoin operation in my project.
Gary, el Pingüino Artefacto
Yeah could be some thing, maybe mismatch of versions between project, but for my case it was by putting "type": "module" in all package.json I had to do a shit ton of refactor to make it :c
Baron Von Enablestein
Thanks for sharing, that's gonna be a Monday problem I guess 😄
Gary, el Pingüino Artefacto
Feel free to tag me if needed Maybe I can help

Did you find this page helpful?