Open bkerin opened 4 days ago
Did it work before you switched to Deno? I've never used Deno so I'm not sure if I can help
I've never tried it not on deno. https://lucia-auth.com says it works on deno but admittedly I'm pretty new to deno (as well as javascript generally) so maybe I'm missing something that normally required to get the types imported right
Did you properly rewrite declare module
? Should be npm:lucia
instead of lucia
.
declare module "npm:lucia" {
interface Register {
Lucia: typeof lucia;
DatabaseUserAttributes: Omit<DatabaseUser, "id">;
}
}
Yes, Following the definition chain (via :ALEGoToDefinition) I eventually hit this chunk in my version of lib/auth.ts
:
declare module "npm:lucia" {
interface Register {
Lucia: typeof lucia;
DatabaseUserAttributes: Omit<DatabaseUser, "id">;
}
}
There were a couple other places in my code where as a result of following the examples on the lucia doc pages I had this though:
declare module "npm:lucia" {
interface Register {
Lucia: typeof lucia;
}
}
ALE offered them as options when following the definition chain from User type (with :ALEGoToDefinition). My understanding of what declare modules is doing is pretty poor but I guess it's declaring ambient types so I guess there's really only supposed to be one of these. So I went through and nuked the other ones in my code, and that make the error vanish from ALE, but it still shows up in deno check. There's still the root definition from node_modules/.deno/lucia@3.2.0/node_modules/lucia/dist/index.d.ts offered:
export interface Register {
}
So maybe deno is for some reason stuck on that one?
I really appreciate your taking time to look at this, I haven't fealt this noob at software in a long time as I have trying to get a grip on the modern javascript/typescript scene. The sad thing is deno looks a heck of a lot easier and cleaner from new person perspective, but I get a little bit of a scary lonely feeling on it. I'm curious how many people you know have lucia working on deno?
Yeah I'm not sure if I can help further, especially since I got mine working in Deno after fixing the module declaration
I'll try the example exactly
Is your working setup on better-sqlite3? I couldn't get that to work on deno even independently: https://github.com/WiseLibs/better-sqlite3/issues/1205
If you ever get a chance to tar up your working setup I'd love to look at it
better-sqlite3
only works in Node
I'm trying to get this example working with Deno and Hono while being pretty new to typescript etc. so sorry if this issue is obvious.
I first changed some tiny things in lib to get it compiling with Deno. Then I started on routes/, and I now get this warning from
deno check
:From that it seems like deno is picking up at least some of the types for Lucia but the User type is not as expected or is not correct somehow. I am wondering what is the mechanism by which the username property is expected to be pulled in? I see that username is a db field but don't understand the mechanism by which it becomes a property of User in this context. I think maybe in this context User is actually known to be of a descendant type and I also need to tell typescript about this somehow?
Any advice appreciated