impersonatedBy missing in admin session
I am using the admin plugin for impersonation. When i get the current data with auth.api.getSession(), the TypeScript type for the session does not include the impersonatedBy field, so when I try to access it for conditional rendering I get a TS error. At runtime it works correctly, and the impersonatedBy field is present in the JS session object as null or with the correct ID. How can I make my auth instance aware I am using the admin plugin so it knows impersonatedBy is in the session object?
Solution:
Jump to solution
Hello, types should had inferred correctly if you're using auth.api and have included the admin plugin.
May I see the
useAuth
hook? @chris...
5 Replies

Property 'impersonatedBy' does not exist on type '{ id: string; createdAt: Date; updatedAt: Date; userId: string; expiresAt: Date; token: string; ipAddress?: string | null | undefined; userAgent?: string | null | undefined; }'
Solution
Hello, types should had inferred correctly if you're using auth.api and have included the admin plugin.
May I see the
useAuth
hook? @chris
On an unrelated note, if
useAuth
is a hook don't forget to include "use client"
in your file 😁yes, once i inferred the type of session from auth.api it worked correctly, thank you @Ping