How do I access the type of the value returned by getInvitation?

It's common in Better Auth to use authClient to query information - for example getInvitation How do I access the type of the value returned by getInvitation? Specifically I am interested in the data
const response = await authClient.organization.getInvitation({
query: {
id: invitationId,
},
})

// What can I replace any with?
const data: any = response.data
const response = await authClient.organization.getInvitation({
query: {
id: invitationId,
},
})

// What can I replace any with?
const data: any = response.data
I tried ReturnType but it returns any:
type GetInvitationResponse = Awaited<ReturnType<typeof authClient.organization.getInvitation>>
type InvitationData = GetInvitationResponse['data']
type GetInvitationResponse = Awaited<ReturnType<typeof authClient.organization.getInvitation>>
type InvitationData = GetInvitationResponse['data']
Solution:
Ah OK - I need to use $Infer with a type assertion ```ts type Invitation = typeof authClient.$Infer.Invitation ...
Jump to solution
2 Replies
Solution
Alex Booker
Alex Booker3mo ago
Ah OK - I need to use $Infer with a type assertion
type Invitation = typeof authClient.$Infer.Invitation

...
const data = response.data as Invitation
type Invitation = typeof authClient.$Infer.Invitation

...
const data = response.data as Invitation
Alex Booker
Alex BookerOP3mo ago
@Ping I noticed the $.Infer.Invitation type is missing organizationName, organizationSlug, inviterEmail, and teamId.

Did you find this page helpful?