Type inference is not working when findFirst is extracted

Hey typescript wizards, could anyone spot what I'm doing wrong here?
type OrgTableQueryParams = Parameters<
typeof db.query.organizationTable.findFirst
>[0] & {};
export const getOrganizationById = cache(
(id: string, queryParams?: OrgTableQueryParams) => {
return db.query.organizationTable.findFirst({
where: (table, { eq }) => eq(table.id, id),
...queryParams,
});
}
);
type OrgTableQueryParams = Parameters<
typeof db.query.organizationTable.findFirst
>[0] & {};
export const getOrganizationById = cache(
(id: string, queryParams?: OrgTableQueryParams) => {
return db.query.organizationTable.findFirst({
where: (table, { eq }) => eq(table.id, id),
...queryParams,
});
}
);
But when I use it like this the types are not getting inferred from the with params:
const organization = await getOrganizationById(user.organizationId, {
with: {
slackWorkspace: {
with: {
channels: true,
},
},
},
});
const organization = await getOrganizationById(user.organizationId, {
with: {
slackWorkspace: {
with: {
channels: true,
},
},
},
});
Thanks 🙏
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server