Open b-novikov-ipersonality opened 2 years ago
The return type can be undefined
(and it is by default):
@balazsorban44 with redirect: false
option it still warns that response
is possibly undefined
.
The fact of redirect is false doesn't infer the response can be undefined, it's only used to show a use case of this feature.
But I agree with you, the docs were not clear about the response can be undefined, I think it's good to improve and make it clear.
If you want a simple solution to this problem, only use optional chaining on the response.
Environment
Reproduction URL
https://codesandbox.io/s/objective-mendel-ixpsco?file=/src/App.tsx
Describe the issue
According to documentation when you supply
email
orcredentials
provider tosignIn
function it returns promise of typeSignInResponse
but in fact return type of thesignIn
function isPromise<SignInResponse | undefined>
.This typing results in typescript error
Object is possibly 'undefined'
if you don't check ifresponse
exists beforehand.How to reproduce
signIn
type to beRedirectableProviderType
then
to function callresponse.error
Expected behavior
When specifying
signIn
type to be one ofRedirectableProviderType
the return type should bePromise<SignInResponse>
and notPromise<SignInResponse | undefined>