The type-check of partial-select doesn't work well
description
On the code
ref: https://orm.drizzle.team/docs/select#partial-select
I bumped into the type error.
I want to use 2, but type check is executed as 1.
How can I fix this...??
Please help me.
version
Drizzle ORM - Select
Drizzle ORM is a lightweight and performant TypeScript ORM with developer experience in mind.
10 Replies
👋 do you have strict mode set to true in your tsconfig?
Thank you for your comment.
This is my tsconfig.
And strict mode set to true, but even when set to false, I cannot solve the problem.
good, strict should always be true.
I have tried with the same code and no error 😦
I wonder what could cause that
I have set up a nextjs project with @cloudflare/workers-types too, still no issues
if you run
next lint
, do you also have this error or is it just in your editor?Thank you for trying...!!!
And when I use your code, it works.
But my code is this. And I found out the global definition make it broken.
(please try it again..??)
Actually I switch driver according to whether the env is local or production.(local: drizzleProxy, production: drizzleTiDB)
And I use global variable because I don't want to make many db instances.
What should I define the type of the global variable??
Or are there any other best practices?
I see what your tried
the
SelectedFields
are incompatible (not the same type) so TS can't infer the partial select
at this point, it is safe to force cast the dev
db client
+ I would store the db in global only in the else
branch to prevent issuesOh...!!! Thank you so much...!!!
It works!!
And what you care about storing the global db is amazing.
i'm getting a similar problem. i'm not really sure what it is. can you help me with this?
i want to select a certain property, but it's not letting me