next-auth
next-auth copied to clipboard
transform SessionContextValue to tagged union type
☕️ Reasoning
Currently SessionContextValue type has a problem that is TSC cannot infer type correctly.
In detail, TSC cannot narrowing to { data: Session; status: "authenticated" } by comparing "status" field.
In code, func1 has a problem that session.data cannot assignable to string even through eliminated possibility data.status is "unauthenticated" or "loading"
🧢 Checklist
- [ ] Documentation
- [x] Tests
- [x] Ready to be merged
🎫 Affected issues
Please scout and link issues that might be solved by this PR.
Fixes: INSERT_ISSUE_LINK_HERE
📌 Resources
- Contributing guidelines
- Code of conduct
- Contributing to Open Source
The latest updates on your projects. Learn more about Vercel for Git ↗︎
1 Ignored Deployment
Name | Status | Preview | Updated |
---|---|---|---|
next-auth | ⬜️ Ignored (Inspect) | Sep 16, 2022 at 11:39AM (UTC) |
Thanks for the PR! 🙌 But I think the current union type is good enough. Any reasons why you are not checking for "authenticated" status directly? That'll give you the correct session type.