encore icon indicating copy to clipboard operation
encore copied to clipboard

Impossible to use infered types from drizzle

Open ToP29 opened this issue 10 months ago • 2 comments

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.

ToP29 avatar Feb 02 '25 02:02 ToP29

I am having the same issue. had to use the separate types

rittamdebnath avatar Feb 02 '25 19:02 rittamdebnath

duplicate of:

  • https://github.com/encoredev/encore/issues/1669

ImBIOS avatar Feb 05 '25 06:02 ImBIOS