Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Impossible to use infered types from drizzle #1745

Open
ToP29 opened this issue Feb 2, 2025 · 2 comments
Open

Impossible to use infered types from drizzle #1745

ToP29 opened this issue Feb 2, 2025 · 2 comments

Comments

@ToP29
Copy link

ToP29 commented Feb 2, 2025

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 ToP29 changed the title Impossible tu use infered types from drizzle Impossible to use infered types from drizzle Feb 2, 2025
@rittamdebnath
Copy link

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

@ImBIOS
Copy link

ImBIOS commented Feb 5, 2025

duplicate of:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants