expo plugin has invalid types #1202

Closed
opened 2026-03-13 08:27:55 -05:00 by GiteaMirror · 6 comments
Owner

Originally created by @vedantroy on GitHub (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;
Originally created by @vedantroy on GitHub (May 14, 2025). ### Is this suited for github? - [x] 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 ```bash - OS: MacOS - Browser: Not relevant ``` ### Which area(s) are affected? (Select all that apply) Backend ### Auth config (if applicable) ```typescript 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; ```
Author
Owner

@Kinfe123 commented on GitHub (May 14, 2025):

can you show your tsconfig file ?

@Kinfe123 commented on GitHub (May 14, 2025): can you show your tsconfig file ?
Author
Owner

@vedantroy commented on GitHub (May 14, 2025):

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

@vedantroy commented on GitHub (May 14, 2025): ``` { "compilerOptions": { "target": "ES2020", "module": "CommonJS", "lib": ["ES2020"], "strict": true, "esModuleInterop": true, "skipLibCheck": true, "forceConsistentCasingInFileNames": true, "baseUrl": ".", "paths": { "@/*": ["../../src/*"] } }, "include": ["**/*.ts"], "exclude": ["node_modules"] } ```
Author
Owner

@Kinfe123 commented on GitHub (May 14, 2025):

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

@Kinfe123 commented on GitHub (May 14, 2025): can you try adding moduleResolutons options here on tsconfig - `"moduleResolution": "bundler"`
Author
Owner

@vedantroy commented on GitHub (May 14, 2025):

@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"]
}
@vedantroy commented on GitHub (May 14, 2025): @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"] } ```
Author
Owner

@vedantroy commented on GitHub (May 15, 2025):

@Kinfe123 I just @//ts-ignore the line, and everything seems to be working. But, I'm not sure if there's a deeper issue here.

@vedantroy commented on GitHub (May 15, 2025): @Kinfe123 I just `@//ts-ignore` the line, and everything seems to be working. But, I'm not sure if there's a deeper issue here.
Author
Owner

@Kinfe123 commented on GitHub (Jun 12, 2025):

@vedantroy can you please update the version and check if this issue still exists ?

@Kinfe123 commented on GitHub (Jun 12, 2025): @vedantroy can you please update the version and check if this issue still exists ?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#1202