© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
Drizzle TeamDT
Drizzle Team•3y ago•
28 replies
mr_pablo

Error when inferring type from db.query

When I try to use
type foo = ReturnType<typeof myQuery>
type foo = ReturnType<typeof myQuery>
I get the following error

Type 'MySql2PreparedQuery<PreparedQueryConfig & { execute: { [x: string]: any; matchPlayers: { [x: string]: any; playerName: { [x: string]: any; } | { [x: string]: any; }[]; } | { [x: string]: any; playerName: { ...; } | { ...; }[]; }[]; matchTeams: { ...; } | { ...; }[]; homeTeam: { ...; } | { ...; }[]; awayTeam: { ...; ...' does not satisfy the constraint '(...args: any) => any'.
Type 'MySql2PreparedQuery<PreparedQueryConfig & { execute: { [x: string]: any; matchPlayers: { [x: string]: any; playerName: { [x: string]: any; } | { [x: string]: any; }[]; } | { [x: string]: any; playerName: { ...; } | { ...; }[]; }[]; matchTeams: { ...; } | { ...; }[]; homeTeam: { ...; } | { ...; }[]; awayTeam: { ...; ...' provides no match for the signature '(...args: any): any'

The query is a prepared statement outside of my class, and I have the type just underneath so it can be used globally by functions inside my class.
Drizzle TeamJoin
The official Discord for all Drizzle related projects, such as Drizzle ORM, Drizzle Kit, Drizzle Studio and more!
11,879Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Properly inferring Prepared Statement Return Type when executing a query
Drizzle TeamDTDrizzle Team / help
2y ago
DB type error
Drizzle TeamDTDrizzle Team / help
3y ago
json column type mismatch when using db.query
Drizzle TeamDTDrizzle Team / help
3y ago
drizzle-orm not inferring type from soft relations
Drizzle TeamDTDrizzle Team / help
15mo ago