nextauthjs / next-auth

Authentication for the Web.
https://authjs.dev
ISC License
24.37k stars 3.41k forks source link

Including undefined in type declaration of 'data' value returned by useSession #8015

Closed nik32 closed 11 months ago

nik32 commented 1 year ago

Question 💬

image

In the docs it is mentioned that data can have 3 values (including undefined)... then can't we include it in the type declaration of 'data'? This got me tripped as I was only checking for a null value (as the TS type specifies it can only be of type 'Session | null' and this led to a very subtle bug. And even TS did not warn me on this mistake as undefined is not specified as a value of 'data')

How to reproduce ☕️

https://codesandbox.io/p/sandbox/github/nextauthjs/next-auth-example/tree/main?file=%2Fcomponents%2Fheader.tsx%3A9%2C37-9%2C47

Contributing 🙌🏽

No, I am afraid I cannot help regarding this

stale[bot] commented 1 year ago

It looks like this issue did not receive any activity for 60 days. It will be closed in 7 days if no further activity occurs. If you think your issue is still relevant, commenting will keep it open. Thanks!

nik32 commented 1 year ago

@balazsorban44 @lluia isn't this a relevant issue?

stale[bot] commented 11 months ago

To keep things tidy, we are closing this issue for now. If you think your issue is still relevant, leave a comment and we might reopen it. Thanks!