-
-
Notifications
You must be signed in to change notification settings - Fork 462
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
[Feature Request]: Migrate to ES module syntax #1074
Comments
+1 - It would also be following Microsoft's recommendations
To note, @juliusmarminge I was able to get this working in a
// File: /packages/auth/app.d.ts
/// <reference types="lucia" />
declare namespace Lucia {
export type Auth = import("./src/lucia").Auth;
// export type DatabaseUserAttributes =
// import("./types").DatabaseUserAttributes;
export interface DatabaseUserAttributes {
username: string;
}
export interface DatabaseSessionAttributes {}
}
![]()
// File: /apps/nextjs/app.d.ts
/// <reference types="@acme/auth/app.d.ts" />
![]() |
Step 3 is a workaround around the problem though. Using modules it just works |
Yup, definitely agreed modules are the way to go, hence my +1. Was just offering a workaround to help with your comment:
|
Hi, sorry for the late response. I tried it out and it looks to work fine. My only issue is that I'm not sure if I can support both namespaces and modules, in which case the change has to be part of v3. |
Another idea would be to completely drop the augmentation and simply specify the types as generics to the adapter (if needed, e.g. prisma should be able to extract the type from the model). |
- Once redis/ioredis#1822 is fixed, remove patch to ioredis - Once Azure/azure-functions-host#162 is fixed, remove patch to nitro that wraps console log. - Once unjs/nitro#1753 is merged and released, remove corresponding patch to nitro - Once lucia-auth/lucia#1153 is fixed, rename models/fields in prisma - Once lucia-auth/lucia#1155 is merged and released, remove custom h3 lucia middleware - Once lucia-auth/lucia#1074 is fixed, remove lucia types shims - Enable CSRF protection in lucia (but then login doesn't work anymore...)
I've been playing around with this for a while, and yeah, I can't support |
@hdwatts Any chance you could link to a working t3-turbo + lucia example please? It seems like I have everything set up properly (the types propagate across packages, as per your example) but I get a 500 error whenever I try to create a user as per the nextJS + app directory tutorial on the site. I am pretty new to this, so a working example to look over would be great. I would also be happy to write it up as a guide if you're interested, @pilcrowOnPaper |
Addressed in v3 (beta) |
Description
Would be better if Lucia supported module augmentation through ES module syntax:
This would improve monorepo support as we could put this declaration in a
.ts
file (.d.ts
files kinda suck in monorepos) and better align with what other repos are doing:As of now, I can't seem to get this to properly work in a monorepo as declaring types in
.d.ts
files don't propagate well through multiple packagesThe text was updated successfully, but these errors were encountered: