-
Notifications
You must be signed in to change notification settings - Fork 113
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot augment user
in UserSession
#31
Comments
I am getting this TypeError in my project as well. I've been ignoring them for a while now as I haven't found a solution to this yet sadly... It seems as if the export async function requireUserSession(event: H3Event) {
const userSession = await getUserSession(event)
if (!userSession.user) {
throw createError({
statusCode: 401,
message: 'Unauthorized'
})
}
return userSession
} It throws an error when (edit) I read microsoft/TypeScript#56528 idk if it is the same issue but it is planned for 5.4.0 |
I manually remove the |
The playground project tries to augment
UserSession
:https://github.com/Atinux/nuxt-auth-utils/blob/e344c9880491346ab73165ac4439c129b13ec15d/playground/auth.d.ts#L3
But
user
is already declared here:https://github.com/Atinux/nuxt-auth-utils/blob/e344c9880491346ab73165ac4439c129b13ec15d/src/runtime/types/session.ts#L2
🤔I don't think it is possible to augment an already declared field of an interface.
Type errors in playground:
![image](https://github.com/Atinux/nuxt-auth-utils/assets/40021217/4ec171cd-9ad4-442f-8082-9e99a6b1a29a)
The text was updated successfully, but these errors were encountered: