Which typescript type should I use for select?
Hi, this question might be confusing. Let me explain the problem, I'm building a common function for drizzle().select() somethine like
you can see I'm getting {[x:string]:never} when I pass {id:number;data:string} on select param.
1 Reply
The
select from
statement in drizzle is a complex class that takes the table, any possible joins, the object passed to select (or the absence of it) and construct the type that will be returned based on all of that.
Typescript is unable to infer the return type because the parameters you are passing to the function are not being structured in the way drizzle does it, and not being passed through to the internal drizzle type system
You can just bypass all that by explicitly telling typescript what the return type is, intead of expecting it to infer it for you
For example: