lucia: [Bug]: type User = any
Package
lucia-auth
Describe the bug
In lucia-auth/auth/index.d.ts there is typescript error: 1. Cannot find namespace ‘Lucia’. [2503]
export type User = ReturnType<Lucia.Auth['_transformDatabaseUser']>
This is internals of the library, but this problem reflect in the code. For example:
const { user } = await event.locals.auth.validateUser()
returns user:any which is not true, because according to validateUser() it should return:
validateUser: () => Promise<{
user: null;
session: null;
} | {
user: User;
session: Session;
}>;
This results in not having type completion when it comes to user object
“lucia-auth”: “^1.8.0”, “@sveltejs/kit”: “^1.20.2”,
About this issue
- Original URL
- State: closed
- Created a year ago
- Comments: 17 (12 by maintainers)
Hi, I’ve faced the same issue, the solution lies in correcting the
Authtype on the.d.tsfile. In the guys case the dynamic import oftype Auth = import('$lib/server/lucia.js').Auth;must not be working, probably because of the svelte’s$libshortcut.@pilcrowOnPaper in v2 I see the types, but user object is located within session – guess this is one of breaking changes from v1 😄