encore
encore copied to clipboard
Impossible to use infered types from drizzle
In monorepo(turborepo) project, I have drizzle as package. From it, a am importing schema and infering inster and select types:
/* user.interfaces.ts */
import { users } from '@repo/drizzle/schema'
export type UsersInsert = typeof users.$inferInsert
export type UsersSelect = typeof users.$inferSelect
But if i try to run encore run it fails with these errors:
│ error: typeof with non-ident not yet supported
│ --> \user\user.interfaces.ts:6:31
│ |
│ 6 | export type UsersInsert = typeof users.$inferInsert
│ | ^^^^^^^^^^^^^^^^^^
│ error: expected named interface type, found Basic(Never)
│ --> \user\user.controller.ts:7:15
│ |
│ 7 | async (data: UsersInsert): Promise<UsersSelect> => {
│ | ^^^^^^^^^^^
If I change types from infered to static, then in works.
/* user.interfaces.ts */
export type UsersInsert = {
firstName: string
lastName: string
displayName: string
email: string
}
export type UsersSelect = {
id: number
firstName: string
lastName: string
displayName: string
email: string
}
But this costs me automatic type safety with drizzle, because I would have to maintain these types separately.
I am having the same issue. had to use the separate types
duplicate of:
- https://github.com/encoredev/encore/issues/1669