8000 `expo` plugin has invalid types · Issue #2652 · better-auth/better-auth · GitHub
[go: up one dir, main page]

Skip to content

expo plugin has invalid types #2652

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

Open
1 task done
vedantroy opened this issue May 14, 2025 · 4 comments
Open
1 task done

expo plugin has invalid types #2652

vedantroy opened this issue May 14, 2025 · 4 comments

Comments

@vedantroy
Copy link
vedantroy commented May 14, 2025

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

Use:

import { expo } from "@better-auth/expo";

and add it to your plugins array.

Current vs. Expected behavior

Expected: it works.
Current:

Type '{ id: "expo"; init: (ctx: AuthContext) => { options: { trustedOrigins: string[]; }; }; onRequest(request: Request, ctx: AuthContext): Promise<{ request: Request; } | undefined>; hooks: { ...; }; }' is not assignable to type 'BetterAuthPlugin'.
  Types of property 'init' are incompatible.
    Type '(ctx: AuthContext) => { options: { trustedOrigins: string[]; }; }' is not assignable to type '(ctx: AuthContext) => void | { context?: { appName?: string | undefined; baseURL?: string | undefined; secret?: string | undefined; secondaryStorage?: { get?: ((key: string) => string | ... 1 more ... | null) | undefined; set?: ((key: string, value: string, ttl?: number | undefined) => void | Promise<...>) | undefin...'.
      Types of parameters 'ctx' and 'ctx' are incompatible.
        Property 'runMigrations' is missing in type 'import("/Users/ved/Desktop/photoai-all/photoai/v1/api/node_modules/better-auth/dist/auth-CEAjdCRr").k' but required in type 'import("/Users/ved/Desktop/photoai-all/photoai/v1/node_modules/better-auth/dist/shared/better-auth.qzSbzJNO").l

What version of Better Auth are you using?

^1.0.22

Provide environment information

- OS: MacOS
- Browser: Not relevant

Which area(s) are affected? (Select all that apply)

Backend

Auth config (if applicable)

import { betterAuth } from "better-auth"
export const auth = betterAuth({
  emailAndPassword: {  
    enabled: true
  },
});

Additional context

const auth = betterAuth({
  database: new Database(DATABASE_URL),
  plugins: [admin(), expo()],
  socialProviders: {
    google: {
      clientId: process.env.AUTH_GOOGLE_ID as string,
      clientSecret: process.env.AUTH_GOOGLE_SECRET as string,
    },
  },
  trustedOrigins,
  user: {},
  databaseHooks: {
    account: {
      create: {
        async after(_user) {
          // Do user init stuff you want ...
          // We don't use this callback b/c, we can't access name/email
        },
      },
    },
  },
});

export default auth;
@Kinfe123
Copy link
Collaborator
Kinfe123 commented May 14, 2025

can you show your tsconfig file ?

@vedantroy
Copy link
Author
{
  "compilerOptions": {
    "target": "ES2020",
    "module": "CommonJS",
    "lib": ["ES2020"],
    "strict": true,
    "esModuleInterop": true,
    "skipLibCheck": true,
    "forceConsistentCasingInFileNames": true,
    "baseUrl": ".",
    "paths": {
      "@/*": ["../../src/*"]
    }
  },
  "include": ["**/*.ts"],
  "exclude": ["node_modules"]
}

@Kinfe123
Copy link
Collaborator

can you try adding moduleResolutons options here on tsconfig - "moduleResolution": "bundler"

@vedantroy
Copy link
Author

@Kinfe123 That didn't work. Here's the error:

src/auth.ts:21:22 - error TS2322: Type '{ id: "expo"; init: (ctx: AuthContext) => { options: { trustedOrigins: string[]; }; }; onRequest(request: Request, ctx: AuthContext): Promise<{ request: Request; } | undefined>; hooks: { ...; }; }' is not assignable to type 'BetterAuthPlugin'.
  Types of property 'init' are incompatible.
    Type '(ctx: AuthContext) => { options: { trustedOrigins: string[]; }; }' is not assignable to type '(ctx: AuthContext) => void | { context?: { logger?: { error?: ((message: string, ...args: any[]) => void) | undefined; info?: ((message: string, ...args: any[]) => void) | undefined; success?: ((message: string, ...args: any[]) => void) | undefined; warn?: ((message: string, ...args: any[]) => void) | undefined; deb...'.
      Types of parameters 'ctx' and 'ctx' are incompatible.
        Property 'runMigrations' is missing in type 'import("/Users/ved/Desktop/photoai-all/photoai/v1/api/node_modules/better-auth/dist/auth-CEAjdCRr").k' but required in type 'import("/Users/ved/Desktop/photoai-all/photoai/v1/node_modules/better-auth/dist/shared/better-auth.qzSbzJNO").l'.

21   plugins: [admin(), expo()],
                        ~~~~~~

  ../node_modules/better-auth/dist/shared/better-auth.qzSbzJNO.d.ts:751:5
    751     runMigrations: () => Promise<void>;
            ~~~~~~~~~~~~~
    'runMigrations' is declared here.

As well as my new tsconfig:

{
  "compilerOptions": {
    "target": "ES2020",
    "module": "ESNext",
    "lib": ["ES2020"],
    "strict": true,
    "moduleResolution": "bundler",
    "esModuleInterop": true,
    "skipLibCheck": true,
    "forceConsistentCasingInFileNames": true,
    "baseUrl": ".",
    "paths": {
      "@/*": ["../../src/*"]
    }
  },
  "include": ["**/*.ts"],
  "exclude": ["node_modules"]
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants
0