You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The parameter user is type any. (I can't find a way to make it type-safe... even if I use UserSession from nuxt-auth-utils, it does not take into account the auth.d.ts file (it just gives out user and secure (which do not have any types within them)
According to my consola (a wrapper around console to make stylish outputs) terminal output:
{id: 1,role: 'ProcurementOfficer'}
TLDR;
I'd like to know how I can make the user parameter type safe by respecting auth.d.ts. I am not sure if I should make a shared/types/user.ts file for this because I don't want to update so many types (both auth.d.ts, my database schema and the new shared/types/user.ts)
The text was updated successfully, but these errors were encountered:
I discovered that the Nuxt module is quite helpful for my projects. However, when I attempted to write type-safe code, I ran into an issue.
With nuxt-auth-utils, I am able to create a type declaration file labelled
auth.d.ts
in the root directory of my project.However, whenever I create an ability in my
shared/utils/abilities.ts
file, I do not get any type-safety when interacting with the authorised user.The parameter
user
is typeany
. (I can't find a way to make it type-safe... even if I use UserSession from nuxt-auth-utils, it does not take into account theauth.d.ts
file (it just gives outuser
andsecure
(which do not have any types within them)According to my consola (a wrapper around console to make stylish outputs) terminal output:
TLDR;
I'd like to know how I can make the user parameter type safe by respecting
auth.d.ts
. I am not sure if I should make ashared/types/user.ts
file for this because I don't want to update so many types (both auth.d.ts, my database schema and the newshared/types/user.ts
)The text was updated successfully, but these errors were encountered: