Open mubaidr opened 1 year ago
@mubaidr In my case error is always undefined, but request is 200. Do you have the same?
@mubaidr In my case error is always undefined, but request is 200. Do you have the same?
The issue is about types not result. Result is fine.
Is there any progress on this? The issue is still present in the newest version even if redirect is true
.
The issue currently consists of the signIn
function returning either:
{ error: string | null, status: number, ok: boolean, url: any }
or void
, based on the input variables.
Ideally, I would like to type the return of the function, based on the input values. However this causes some more issues:
void
is returned (this cannot be known when the input is given)void
is returned (also don't know this when the input is given)One "dirty" way to ensure we have better type support is to always return { error: string | null, status: number, ok: boolean, url: any }
, but keep the values undefined, in the case a void would be returned. I had a look at Conditional Types, to make it more pretty, but I feel like our setup is too complex to properly integrate conditional types to support all possible returns.
The current ways this issue impacts developer is:
const result = await signIn('credentials', {
callbackUrl: '/',
username: 'jsmith',
password: 'hunter2',
redirect: false,
})
result
signIn
function, with proper types (const { error } = signIn()
-> error is typed as any, even though we define it as a string or null)This does pose some problems, when trying to further manage the result
What's the second solution to this you mentioned in our talk?
and: which solution do you prefer? (:
What's the second solution to this you mentioned in our talk?
The two solutions were:
Could you please provide an example of how to get the proper type here when using the signIn method?
That void gets to me.
Environment
Reproduction
redirect: false
Describe the bug
Typescript does not recognize type of
SignInResult
type, therefore unabel to extracterror
orurl
from result without specifying // @ts-ignoreAdditional context
Logs
No response
P.S. Great job on this module! This was the missing puzzle piece for Nuxt 3. 🥳