[GH-ISSUE #1252] Sluggish Typescript performance #8660

Closed
opened 2026-04-13 03:48:59 -05:00 by GiteaMirror · 16 comments
Owner

Originally created by @BjoernRave on GitHub (Jan 21, 2025).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/1252

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

Open cursor with a file where sth related to better-auth is used.

Current vs. Expected behavior

For some reason typescript is suuper slow when dealing with anything from better-auth.

Not sure if anyone else experiences the same, also not sure how to go about sth like that, maybe someone has an idea. Happy to provide more details.

What version of Better Auth are you using?

1.1.4

Provide environment information

MacOS
cursor

part of a turborepo/pnpm monorepo.


    "typescript": "5.7.2"
  "better-auth": "^1.1.14",

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

Types

Auth config (if applicable)

my init: 


import { prisma } from "@scoutello/db"
import { sendMail } from "@scoutello/mail"
import { betterAuth } from "better-auth"

import { prismaAdapter } from "better-auth/adapters/prisma"
import { bearer, emailOTP, organization } from "better-auth/plugins"

export const auth: any = betterAuth({
  appName: "Scoutello",
  database: prismaAdapter(prisma, {
    provider: "postgresql", // or "mysql", "postgresql", ...etc,
  }),
  session: {
    freshAge: 0,
  },
  emailVerification: {
    async sendVerificationEmail({ user, url }) {
      await sendMail({
        to: user.email,
        type: "verify-mail",
        variables: {
          verifyLink: url,
        },
        language: "de",
      })
    },
  },
  account: {
    accountLinking: {
      trustedProviders: ["google", "microsoft", "linkedin"],
    },
  },
  emailAndPassword: {
    enabled: true,
    async sendResetPassword({ user, url }) {
      await sendMail({
        to: user.email,
        type: "reset-password",
        variables: {
          resetLink: url,
          username: user.email,
        },
        language: "de",
      })
    },
  },
  socialProviders: {
    google: {
      clientId: process.env.NEXT_PUBLIC_GOOGLE_CLIENT_ID || "",
      clientSecret: process.env.GOOGLE_CLIENT_SECRET || "",
    },
    microsoft: {
      clientId: process.env.MICROSOFT_CLIENT_ID || "",
      clientSecret: process.env.MICROSOFT_CLIENT_SECRET || "",
    },
    linkedin: {
      clientId: process.env.LINKEDIN_CLIENT_ID || "",
      clientSecret: process.env.LINKEDIN_CLIENT_SECRET || "",
    },
  },
  plugins: [
    organization({
      async sendInvitationEmail(data) {
        await sendMail({
          to: data.email,
          type: "invite-user",
          variables: {
            username: data.email,
            invitedByUsername: data.inviter.user.name,
            invitedByEmail: data.inviter.user.email,
            teamName: data.organization.name,
            inviteLink:
              process.env.NODE_ENV === "development"
                ? `http://localhost:3000/accept-invitation/${data.id}`
                : `${
                    process.env.BETTER_AUTH_URL ||
                    "https://demo.better-auth.com"
                  }/accept-invitation/${data.id}`,
          },
          language: "de",
        })
      },
    }),
    emailOTP({
      async sendVerificationOTP({ email, otp, type }) {
        await sendMail({
          to: email,
          type: "send-otp",
          variables: {
            otp,
            username: email,
          },
          language: "de",
        })
      },
    }),
    bearer(),
  ],
})


my client: 



import { Preferences } from "@capacitor/preferences"
import { emailOTPClient } from "better-auth/client/plugins"
import { createAuthClient } from "better-auth/react"
import { toast } from "sonner"
import { AUTH_TOKEN } from "@scoutello/shared/constants"
export const client = createAuthClient({
  plugins: [emailOTPClient()],
  fetchOptions: {
    onError(e) {
      if (e.error.status === 429) {
        toast.error("Too many requests. Please try again later.")
      }
    },
    auth: {
      type: "Bearer",
      token: () =>
        Preferences.get({ key: AUTH_TOKEN }).then((res) => res.value) || "", // get the token from localStorage
    },
  },
})

export const {
  signUp,
  signIn,
  signOut,
  useSession,
  organization,
  useListOrganizations,
  useActiveOrganization,
  emailOtp,
} = client

Additional context

No response

Originally created by @BjoernRave on GitHub (Jan 21, 2025). Original GitHub issue: https://github.com/better-auth/better-auth/issues/1252 ### Is this suited for github? - [x] Yes, this is suited for github ### To Reproduce Open cursor with a file where sth related to better-auth is used. ### Current vs. Expected behavior For some reason typescript is suuper slow when dealing with anything from `better-auth`. Not sure if anyone else experiences the same, also not sure how to go about sth like that, maybe someone has an idea. Happy to provide more details. ### What version of Better Auth are you using? 1.1.4 ### Provide environment information ```bash MacOS cursor part of a turborepo/pnpm monorepo. "typescript": "5.7.2" "better-auth": "^1.1.14", ``` ### Which area(s) are affected? (Select all that apply) Types ### Auth config (if applicable) ```typescript my init: import { prisma } from "@scoutello/db" import { sendMail } from "@scoutello/mail" import { betterAuth } from "better-auth" import { prismaAdapter } from "better-auth/adapters/prisma" import { bearer, emailOTP, organization } from "better-auth/plugins" export const auth: any = betterAuth({ appName: "Scoutello", database: prismaAdapter(prisma, { provider: "postgresql", // or "mysql", "postgresql", ...etc, }), session: { freshAge: 0, }, emailVerification: { async sendVerificationEmail({ user, url }) { await sendMail({ to: user.email, type: "verify-mail", variables: { verifyLink: url, }, language: "de", }) }, }, account: { accountLinking: { trustedProviders: ["google", "microsoft", "linkedin"], }, }, emailAndPassword: { enabled: true, async sendResetPassword({ user, url }) { await sendMail({ to: user.email, type: "reset-password", variables: { resetLink: url, username: user.email, }, language: "de", }) }, }, socialProviders: { google: { clientId: process.env.NEXT_PUBLIC_GOOGLE_CLIENT_ID || "", clientSecret: process.env.GOOGLE_CLIENT_SECRET || "", }, microsoft: { clientId: process.env.MICROSOFT_CLIENT_ID || "", clientSecret: process.env.MICROSOFT_CLIENT_SECRET || "", }, linkedin: { clientId: process.env.LINKEDIN_CLIENT_ID || "", clientSecret: process.env.LINKEDIN_CLIENT_SECRET || "", }, }, plugins: [ organization({ async sendInvitationEmail(data) { await sendMail({ to: data.email, type: "invite-user", variables: { username: data.email, invitedByUsername: data.inviter.user.name, invitedByEmail: data.inviter.user.email, teamName: data.organization.name, inviteLink: process.env.NODE_ENV === "development" ? `http://localhost:3000/accept-invitation/${data.id}` : `${ process.env.BETTER_AUTH_URL || "https://demo.better-auth.com" }/accept-invitation/${data.id}`, }, language: "de", }) }, }), emailOTP({ async sendVerificationOTP({ email, otp, type }) { await sendMail({ to: email, type: "send-otp", variables: { otp, username: email, }, language: "de", }) }, }), bearer(), ], }) my client: import { Preferences } from "@capacitor/preferences" import { emailOTPClient } from "better-auth/client/plugins" import { createAuthClient } from "better-auth/react" import { toast } from "sonner" import { AUTH_TOKEN } from "@scoutello/shared/constants" export const client = createAuthClient({ plugins: [emailOTPClient()], fetchOptions: { onError(e) { if (e.error.status === 429) { toast.error("Too many requests. Please try again later.") } }, auth: { type: "Bearer", token: () => Preferences.get({ key: AUTH_TOKEN }).then((res) => res.value) || "", // get the token from localStorage }, }, }) export const { signUp, signIn, signOut, useSession, organization, useListOrganizations, useActiveOrganization, emailOtp, } = client ``` ### Additional context _No response_
GiteaMirror added the lockedbug labels 2026-04-13 03:48:59 -05:00
Author
Owner

@Bekacru commented on GitHub (Jan 21, 2025):

could you share your tsconfig and are you using better auth as a dedicated auth package in your monorepo or just installed directly in the app?

<!-- gh-comment-id:2603804750 --> @Bekacru commented on GitHub (Jan 21, 2025): could you share your tsconfig and are you using better auth as a dedicated auth package in your monorepo or just installed directly in the app?
Author
Owner

@BjoernRave commented on GitHub (Jan 21, 2025):

I have a base tsconfig, which is this:

{
  "$schema": "https://json.schemastore.org/tsconfig",
  "compilerOptions": {
    "target": "ES2017",
    "lib": ["dom", "dom.iterable", "esnext"],
    "allowJs": true,
    "checkJs": true,
    "skipLibCheck": true,
    "strict": false,
    "forceConsistentCasingInFileNames": true,
    "noEmit": true,
    "esModuleInterop": true,
    "module": "esnext",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "jsx": "preserve",
    "incremental": true,
    "noUncheckedIndexedAccess": true,
    "downlevelIteration": true,
    "strictNullChecks": false,
    "baseUrl": ".",
    "paths": {
      "@/*": ["*"]
    },
    "moduleResolution": "bundler",
    "assumeChangesOnlyAffectDirectDependencies": true,
    "tsBuildInfoFile": "../../.tsbuildinfo",
    "composite": true
  },
  "exclude": [
    "node_modules",
    "**/node_modules",
    "**/build",
    "**/dist",
    "**/.next",
    "**/out",
    "**/ios",
    "**/android",
    "**/valhalla-files",
    "**/output",
    "**/scoutello-py"
  ]
}

and then in the app where I tried it:

{
  "extends": "../../tooling/typescript/base.json",
  "compilerOptions": {
    "tsBuildInfoFile": ".next/.tsbuildinfo",
    "outDir": ".next",
    "rootDir": ".",
    "baseUrl": ".",
    "paths": {
      "@/*": [
        "./*"
      ]
    },
    "plugins": [
      {
        "name": "next"
      }
    ]
  },
  "include": [
    "next-env.d.ts",
    "**/*.ts",
    "**/*.tsx",
    ".next/types/**/*.ts"
  ],
  "exclude": [
    "node_modules",
    ".next",
    "out"
  ]
}

Not sure what you mean with thtat question. I installed better-auth using pnpm in both my packages/shared package, where the init stuff lives and then in pacakges/ui where the client lib init lives

<!-- gh-comment-id:2604405916 --> @BjoernRave commented on GitHub (Jan 21, 2025): I have a base tsconfig, which is this: ``` { "$schema": "https://json.schemastore.org/tsconfig", "compilerOptions": { "target": "ES2017", "lib": ["dom", "dom.iterable", "esnext"], "allowJs": true, "checkJs": true, "skipLibCheck": true, "strict": false, "forceConsistentCasingInFileNames": true, "noEmit": true, "esModuleInterop": true, "module": "esnext", "resolveJsonModule": true, "isolatedModules": true, "jsx": "preserve", "incremental": true, "noUncheckedIndexedAccess": true, "downlevelIteration": true, "strictNullChecks": false, "baseUrl": ".", "paths": { "@/*": ["*"] }, "moduleResolution": "bundler", "assumeChangesOnlyAffectDirectDependencies": true, "tsBuildInfoFile": "../../.tsbuildinfo", "composite": true }, "exclude": [ "node_modules", "**/node_modules", "**/build", "**/dist", "**/.next", "**/out", "**/ios", "**/android", "**/valhalla-files", "**/output", "**/scoutello-py" ] } ``` and then in the app where I tried it: ``` { "extends": "../../tooling/typescript/base.json", "compilerOptions": { "tsBuildInfoFile": ".next/.tsbuildinfo", "outDir": ".next", "rootDir": ".", "baseUrl": ".", "paths": { "@/*": [ "./*" ] }, "plugins": [ { "name": "next" } ] }, "include": [ "next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts" ], "exclude": [ "node_modules", ".next", "out" ] } ``` Not sure what you mean with thtat question. I installed better-auth using pnpm in both my `packages/shared` package, where the init stuff lives and then in `pacakges/ui` where the client lib init lives
Author
Owner

@Bekacru commented on GitHub (Jan 21, 2025):

@BjoernRave make sure to set strict:true in your ts config and let me know if you still have an issue

<!-- gh-comment-id:2604712928 --> @Bekacru commented on GitHub (Jan 21, 2025): @BjoernRave make sure to set `strict:true` in your ts config and let me know if you still have an issue
Author
Owner

@BjoernRave commented on GitHub (Jan 21, 2025):

thats not really an option for me, since the repo is not setup like this and it would result in loots of type issues, but I guess I can try to see if it makes a difference.

<!-- gh-comment-id:2604754577 --> @BjoernRave commented on GitHub (Jan 21, 2025): thats not really an option for me, since the repo is not setup like this and it would result in loots of type issues, but I guess I can try to see if it makes a difference.
Author
Owner

@Bekacru commented on GitHub (Jan 21, 2025):

@BjoernRave strict:true is required since Better Auth heavily relies on zod and zod types which requires strict to be set to true.

<!-- gh-comment-id:2604759867 --> @Bekacru commented on GitHub (Jan 21, 2025): @BjoernRave `strict:true` is required since Better Auth heavily relies on zod and zod types which requires strict to be set to true.
Author
Owner

@BjoernRave commented on GitHub (Jan 21, 2025):

I am already using zod in that project without strict: true. I know the limitations of that, but for me I never experienced any TS performance issues due to that.

I just turned it on in my project to check if it would make a difference and it still feels pretty slow, maybe it got a little better, not quite sure, but definitely different than any other library I am using (and I use trpc in that project too, which does a lot of type juggling)

<!-- gh-comment-id:2604777289 --> @BjoernRave commented on GitHub (Jan 21, 2025): I am already using zod in that project without `strict: true`. I know the limitations of that, but for me I never experienced any TS performance issues due to that. I just turned it on in my project to check if it would make a difference and it still feels pretty slow, maybe it got a little better, not quite sure, but definitely different than any other library I am using (and I use trpc in that project too, which does a lot of type juggling)
Author
Owner

@ping-maxwell commented on GitHub (Jan 26, 2025):

I could be totally wrong here, but I'm not so sure there is much else you can do...
Better Auth juggles types very hard because it relies heavily on a plugin system and everything can be unique and customized.
Arguably Better Auth juggles types harder than tRPC would - just a guess though.

<!-- gh-comment-id:2614452401 --> @ping-maxwell commented on GitHub (Jan 26, 2025): I could be totally wrong here, but I'm not so sure there is much else you can do... Better Auth juggles types very hard because it relies heavily on a plugin system and everything can be unique and customized. Arguably Better Auth juggles types harder than tRPC would - just a guess though.
Author
Owner

@saevarb commented on GitHub (Jan 28, 2025):

I am also having some rather poor typescript performance. Just a very basic setup like

import { genericOAuthClient } from "better-auth/client/plugins";
import { createAuthClient } from "better-auth/react";

export const authClient = createAuthClient({
  baseURL: "http://localhost:3000",
  plugins: [genericOAuthClient()],
});

Becomes the slowest file to type-check in my codebase (identified by following the steps here). It's also pretty well-known at this point that zod tends to lead to poor type-checking perf.

Here is the output from @typescript/analyze-trace

ot Spots
└─ Check file <myrepo>/src/auth/client.ts (558ms)
   └─ Check variable declaration from (line 6, char 14) to (line 9, char 3) (558ms)
      └─ Check expression from (line 6, char 27) to (line 9, char 3) (558ms)
         └─ Compare types 45900 and 45956 (474ms)
            └─ Determine variance of type 45934 (374ms)
               └─ Compare types 54972 and 52732 (261ms)
                  ├─ {"id":54972,"kind":"GenericTypeAlias","name":"Handler","aliasTypeArguments":[48,45936,45937],"location":{"path":"<myrepo>/node_modules/.pnpm/better-call@0.3.3-beta.4/node_modules/better-call/dist/router-DtwxtvxY.d.ts","line":380,"char":1}}
                  │  ├─ {"id":48,"kind":"TypeParameter"}
                  │  ├─ {"id":45936,"kind":"TypeParameter","name":"Opts","location":{"path":"<myrepo>/node_modules/.pnpm/better-call@0.3.3-beta.4/node_modules/better-call/dist/router-DtwxtvxY.d.ts","line":380,"char":35}}
                  │  └─ {"id":45937,"kind":"TypeParameter","name":"R","location":{"path":"<myrepo>/node_modules/.pnpm/better-call@0.3.3-beta.4/node_modules/better-call/dist/router-DtwxtvxY.d.ts","line":380,"char":65}}
                  └─ {"id":52732,"kind":"GenericTypeAlias","name":"Handler","aliasTypeArguments":[46,45936,45937],"location":{"path":"<myrepo>/node_modules/.pnpm/better-call@0.3.3-beta.4/node_modules/better-call/dist/router-DtwxtvxY.d.ts","line":380,"char":1}}
                     ├─ {"id":46,"kind":"TypeParameter"}
                     ├─ {"id":45936,"kind":"TypeParameter","name":"Opts","location":{"path":"<myrepo>/node_modules/.pnpm/better-call@0.3.3-beta.4/node_modules/better-call/dist/router-DtwxtvxY.d.ts","line":380,"char":35}}
                     └─ {"id":45937,"kind":"TypeParameter","name":"R","location":{"path":"<myrepo>/node_modules/.pnpm/better-call@0.3.3-beta.4/node_modules/better-call/dist/router-DtwxtvxY.d.ts","line":380,"char":65}}

<!-- gh-comment-id:2618228780 --> @saevarb commented on GitHub (Jan 28, 2025): I am also having some rather poor typescript performance. Just a very basic setup like ```ts import { genericOAuthClient } from "better-auth/client/plugins"; import { createAuthClient } from "better-auth/react"; export const authClient = createAuthClient({ baseURL: "http://localhost:3000", plugins: [genericOAuthClient()], }); ``` Becomes the slowest file to type-check in my codebase (identified by following the steps [here](https://github.com/microsoft/TypeScript-wiki/blob/main/Performance-Tracing.md)). It's also pretty well-known at this point that zod tends to lead to poor type-checking perf. Here is the output from @typescript/analyze-trace ``` ot Spots └─ Check file <myrepo>/src/auth/client.ts (558ms) └─ Check variable declaration from (line 6, char 14) to (line 9, char 3) (558ms) └─ Check expression from (line 6, char 27) to (line 9, char 3) (558ms) └─ Compare types 45900 and 45956 (474ms) └─ Determine variance of type 45934 (374ms) └─ Compare types 54972 and 52732 (261ms) ├─ {"id":54972,"kind":"GenericTypeAlias","name":"Handler","aliasTypeArguments":[48,45936,45937],"location":{"path":"<myrepo>/node_modules/.pnpm/better-call@0.3.3-beta.4/node_modules/better-call/dist/router-DtwxtvxY.d.ts","line":380,"char":1}} │ ├─ {"id":48,"kind":"TypeParameter"} │ ├─ {"id":45936,"kind":"TypeParameter","name":"Opts","location":{"path":"<myrepo>/node_modules/.pnpm/better-call@0.3.3-beta.4/node_modules/better-call/dist/router-DtwxtvxY.d.ts","line":380,"char":35}} │ └─ {"id":45937,"kind":"TypeParameter","name":"R","location":{"path":"<myrepo>/node_modules/.pnpm/better-call@0.3.3-beta.4/node_modules/better-call/dist/router-DtwxtvxY.d.ts","line":380,"char":65}} └─ {"id":52732,"kind":"GenericTypeAlias","name":"Handler","aliasTypeArguments":[46,45936,45937],"location":{"path":"<myrepo>/node_modules/.pnpm/better-call@0.3.3-beta.4/node_modules/better-call/dist/router-DtwxtvxY.d.ts","line":380,"char":1}} ├─ {"id":46,"kind":"TypeParameter"} ├─ {"id":45936,"kind":"TypeParameter","name":"Opts","location":{"path":"<myrepo>/node_modules/.pnpm/better-call@0.3.3-beta.4/node_modules/better-call/dist/router-DtwxtvxY.d.ts","line":380,"char":35}} └─ {"id":45937,"kind":"TypeParameter","name":"R","location":{"path":"<myrepo>/node_modules/.pnpm/better-call@0.3.3-beta.4/node_modules/better-call/dist/router-DtwxtvxY.d.ts","line":380,"char":65}} ```
Author
Owner

@arlyon commented on GitHub (Jan 29, 2025):

An option you can try is to enable isolatedDeclarations. You will get a typescript lint that prompts to fill in the type for you, so have it do so and then turn isolatedDeclarations off again. You could then put that type in a different file.

Note that if you make changes (update plugins etc) this file will need to be regenerated, but for other code referencing that variable things should be much much faster.

<!-- gh-comment-id:2621177411 --> @arlyon commented on GitHub (Jan 29, 2025): An option you can try is to enable isolatedDeclarations. You will get a typescript lint that prompts to fill in the type for you, so have it do so and then turn isolatedDeclarations off again. You could then put that type in a different file. Note that if you make changes (update plugins etc) this file will need to be regenerated, but for other code referencing that variable things should be much much faster.
Author
Owner

@dotamir commented on GitHub (Jan 29, 2025):

I do have this issue even with scrict: true. Any file that contains authClient or auth is sooo slow.

<!-- gh-comment-id:2621876459 --> @dotamir commented on GitHub (Jan 29, 2025): I do have this issue even with `scrict: true`. Any file that contains `authClient` or `auth` is sooo slow.
Author
Owner

@ping-maxwell commented on GitHub (Feb 10, 2025):

There should be big performance improvements in the up-coming v1.2 release.
Hopefully this should address a lot of the concern here.

<!-- gh-comment-id:2646862174 --> @ping-maxwell commented on GitHub (Feb 10, 2025): There should be big performance improvements in the up-coming v1.2 release. Hopefully this should address a lot of the concern here.
Author
Owner

@Bekacru commented on GitHub (Feb 12, 2025):

Some of the improvements are already landed on our beta for v1.2 better-auth@beta. Feel free to give feedback on its state.

<!-- gh-comment-id:2653405756 --> @Bekacru commented on GitHub (Feb 12, 2025): Some of the improvements are already landed on our beta for v1.2 `better-auth@beta`. Feel free to give feedback on its state.
Author
Owner

@michaelhays commented on GitHub (Feb 21, 2025):

better-auth@1.2.0-beta.11 fixes this for me!

(Note that better-auth@beta currently points to 1.1.20-beta.1, not 1.2.0-beta.11)

<!-- gh-comment-id:2675459743 --> @michaelhays commented on GitHub (Feb 21, 2025): `better-auth@1.2.0-beta.11` fixes this for me! (Note that `better-auth@beta` currently points to `1.1.20-beta.1`, not `1.2.0-beta.11`)
Author
Owner

@saevarb commented on GitHub (Feb 22, 2025):

I've tried both beta.1 and beta.11 and unfortunately it currently breaks on the generic oauth provider:

src/auth/client.ts:9:13 - error TS2322: Type '{ id: "generic-oauth-client"; $InferServerPlugin: { id: "generic-oauth"; init: (ctx: AuthContext) => { context: { socialProviders: OAuthProvider<Record<string, any>>[]; }; }; endpoints: { ...; }; $ERROR_CODES: { ...; }; }; }' is not assignable to type 'BetterAuthClientPlugin'.
  The types of '$InferServerPlugin.endpoints' are incompatible between these types.
    Type '{ signInWithOAuth2: { <C extends [{ body: { providerId: string; scopes?: string[] | undefined; callbackURL?: string | undefined; errorCallbackURL?: string | undefined; newUserCallbackURL?: string | undefined; disableRedirect?: boolean | undefined; }; method?: "POST" | undefined; query?: Record<string, any> | undefin...' is not assignable to type '{ [key: string]: Endpoint; }'.
      Property 'signInWithOAuth2' is incompatible with index signature.
        Type '{ <C extends [{ body: { providerId: string; scopes?: string[] | undefined; callbackURL?: string | undefined; errorCallbackURL?: string | undefined; newUserCallbackURL?: string | undefined; disableRedirect?: boolean | undefined; }; method?: "POST" | undefined; query?: Record<string, any> | undefined; params?: Record<...' is not assignable to type 'Endpoint'.
          Type '{ <C extends [{ body: { providerId: string; scopes?: string[] | undefined; callbackURL?: string | undefined; errorCallbackURL?: string | undefined; newUserCallbackURL?: string | undefined; disableRedirect?: boolean | undefined; }; method?: "POST" | undefined; query?: Record<string, any> | undefined; params?: Record<...' is not assignable to type '{ options: EndpointOptions; path: string; }'.
            The types of 'options.metadata.openapi.responses' are incompatible between these types.
              Type '{ 200: { description: string; content: { "application/json": { schema: { type: string; properties: { url: { type: string; }; redirect: { type: string; }; }; }; }; }; }; }' is not assignable to type '{ [status: string]: { description: string; content?: { "application/json"?: { schema: { type?: OpenAPISchemaType | undefined; properties?: Record<string, any> | undefined; required?: string[] | undefined; $ref?: string | undefined; }; } | undefined; "text/plain"?: { ...; } | undefined; "text/html"?: { ...; } | undef...'.
                Property '200' is incompatible with index signature.
                  Type '{ description: string; content: { "application/json": { schema: { type: string; properties: { url: { type: string; }; redirect: { type: string; }; }; }; }; }; }' is not assignable to type '{ description: string; content?: { "application/json"?: { schema: { type?: OpenAPISchemaType | undefined; properties?: Record<string, any> | undefined; required?: string[] | undefined; $ref?: string | undefined; }; } | undefined; "text/plain"?: { ...; } | undefined; "text/html"?: { ...; } | undefined; } | undefined; }'.
                    The types of 'content["application/json"].schema.type' are incompatible between these types.
                      Type 'string' is not assignable to type 'OpenAPISchemaType | undefined'.

9   plugins: [genericOAuthClient()],
              ~~~~~~~~~~~~~~~~~~~~

src/auth/server.ts:24:5 - error TS2322: Type '{ id: "generic-oauth"; init: (ctx: AuthContext) => { context: { socialProviders: OAuthProvider<Record<string, any>>[]; }; }; endpoints: { signInWithOAuth2: { ...; }; oAuth2Callback: { ...; }; oAuth2LinkAccount: { ...; }; }; $ERROR_CODES: { ...; }; }' is not assignable to type 'BetterAuthPlugin'.
  Types of property 'endpoints' are incompatible.
    Type '{ signInWithOAuth2: { <C extends [{ body: { providerId: string; scopes?: string[] | undefined; callbackURL?: string | undefined; errorCallbackURL?: string | undefined; newUserCallbackURL?: string | undefined; disableRedirect?: boolean | undefined; }; method?: "POST" | undefined; query?: Record<string, any> | undefin...' is not assignable to type '{ [key: string]: Endpoint; }'.
      Property 'signInWithOAuth2' is incompatible with index signature.
        Type '{ <C extends [{ body: { providerId: string; scopes?: string[] | undefined; callbackURL?: string | undefined; errorCallbackURL?: string | undefined; newUserCallbackURL?: string | undefined; disableRedirect?: boolean | undefined; }; method?: "POST" | undefined; query?: Record<string, any> | undefined; params?: Record<...' is not assignable to type 'Endpoint'.
          Type '{ <C extends [{ body: { providerId: string; scopes?: string[] | undefined; callbackURL?: string | undefined; errorCallbackURL?: string | undefined; newUserCallbackURL?: string | undefined; disableRedirect?: boolean | undefined; }; method?: "POST" | undefined; query?: Record<string, any> | undefined; params?: Record<...' is not assignable to type '{ options: EndpointOptions; path: string; }'.
            The types of 'options.metadata.openapi.responses' are incompatible between these types.
              Type '{ 200: { description: string; content: { "application/json": { schema: { type: string; properties: { url: { type: string; }; redirect: { type: string; }; }; }; }; }; }; }' is not assignable to type '{ [status: string]: { description: string; content?: { "application/json"?: { schema: { type?: OpenAPISchemaType | undefined; properties?: Record<string, any> | undefined; required?: string[] | undefined; $ref?: string | undefined; }; } | undefined; "text/plain"?: { ...; } | undefined; "text/html"?: { ...; } | undef...'.
                Property '200' is incompatible with index signature.
                  Type '{ description: string; content: { "application/json": { schema: { type: string; properties: { url: { type: string; }; redirect: { type: string; }; }; }; }; }; }' is not assignable to type '{ description: string; content?: { "application/json"?: { schema: { type?: OpenAPISchemaType | undefined; properties?: Record<string, any> | undefined; required?: string[] | undefined; $ref?: string | undefined; }; } | undefined; "text/plain"?: { ...; } | undefined; "text/html"?: { ...; } | undefined; } | undefined; }'.
                    The types of 'content["application/json"].schema.type' are incompatible between these types.
                      Type 'string' is not assignable to type 'OpenAPISchemaType | undefined'.

 24     genericOAuth({
        ~~~~~~~~~~~~~~
 25       config: [
    ~~~~~~~~~~~~~~~
... 
 52       ],
    ~~~~~~~~
 53     }),
    ~~~~~~
<!-- gh-comment-id:2676268573 --> @saevarb commented on GitHub (Feb 22, 2025): I've tried both beta.1 and beta.11 and unfortunately it currently breaks on the generic oauth provider: ```ts src/auth/client.ts:9:13 - error TS2322: Type '{ id: "generic-oauth-client"; $InferServerPlugin: { id: "generic-oauth"; init: (ctx: AuthContext) => { context: { socialProviders: OAuthProvider<Record<string, any>>[]; }; }; endpoints: { ...; }; $ERROR_CODES: { ...; }; }; }' is not assignable to type 'BetterAuthClientPlugin'. The types of '$InferServerPlugin.endpoints' are incompatible between these types. Type '{ signInWithOAuth2: { <C extends [{ body: { providerId: string; scopes?: string[] | undefined; callbackURL?: string | undefined; errorCallbackURL?: string | undefined; newUserCallbackURL?: string | undefined; disableRedirect?: boolean | undefined; }; method?: "POST" | undefined; query?: Record<string, any> | undefin...' is not assignable to type '{ [key: string]: Endpoint; }'. Property 'signInWithOAuth2' is incompatible with index signature. Type '{ <C extends [{ body: { providerId: string; scopes?: string[] | undefined; callbackURL?: string | undefined; errorCallbackURL?: string | undefined; newUserCallbackURL?: string | undefined; disableRedirect?: boolean | undefined; }; method?: "POST" | undefined; query?: Record<string, any> | undefined; params?: Record<...' is not assignable to type 'Endpoint'. Type '{ <C extends [{ body: { providerId: string; scopes?: string[] | undefined; callbackURL?: string | undefined; errorCallbackURL?: string | undefined; newUserCallbackURL?: string | undefined; disableRedirect?: boolean | undefined; }; method?: "POST" | undefined; query?: Record<string, any> | undefined; params?: Record<...' is not assignable to type '{ options: EndpointOptions; path: string; }'. The types of 'options.metadata.openapi.responses' are incompatible between these types. Type '{ 200: { description: string; content: { "application/json": { schema: { type: string; properties: { url: { type: string; }; redirect: { type: string; }; }; }; }; }; }; }' is not assignable to type '{ [status: string]: { description: string; content?: { "application/json"?: { schema: { type?: OpenAPISchemaType | undefined; properties?: Record<string, any> | undefined; required?: string[] | undefined; $ref?: string | undefined; }; } | undefined; "text/plain"?: { ...; } | undefined; "text/html"?: { ...; } | undef...'. Property '200' is incompatible with index signature. Type '{ description: string; content: { "application/json": { schema: { type: string; properties: { url: { type: string; }; redirect: { type: string; }; }; }; }; }; }' is not assignable to type '{ description: string; content?: { "application/json"?: { schema: { type?: OpenAPISchemaType | undefined; properties?: Record<string, any> | undefined; required?: string[] | undefined; $ref?: string | undefined; }; } | undefined; "text/plain"?: { ...; } | undefined; "text/html"?: { ...; } | undefined; } | undefined; }'. The types of 'content["application/json"].schema.type' are incompatible between these types. Type 'string' is not assignable to type 'OpenAPISchemaType | undefined'. 9 plugins: [genericOAuthClient()], ~~~~~~~~~~~~~~~~~~~~ src/auth/server.ts:24:5 - error TS2322: Type '{ id: "generic-oauth"; init: (ctx: AuthContext) => { context: { socialProviders: OAuthProvider<Record<string, any>>[]; }; }; endpoints: { signInWithOAuth2: { ...; }; oAuth2Callback: { ...; }; oAuth2LinkAccount: { ...; }; }; $ERROR_CODES: { ...; }; }' is not assignable to type 'BetterAuthPlugin'. Types of property 'endpoints' are incompatible. Type '{ signInWithOAuth2: { <C extends [{ body: { providerId: string; scopes?: string[] | undefined; callbackURL?: string | undefined; errorCallbackURL?: string | undefined; newUserCallbackURL?: string | undefined; disableRedirect?: boolean | undefined; }; method?: "POST" | undefined; query?: Record<string, any> | undefin...' is not assignable to type '{ [key: string]: Endpoint; }'. Property 'signInWithOAuth2' is incompatible with index signature. Type '{ <C extends [{ body: { providerId: string; scopes?: string[] | undefined; callbackURL?: string | undefined; errorCallbackURL?: string | undefined; newUserCallbackURL?: string | undefined; disableRedirect?: boolean | undefined; }; method?: "POST" | undefined; query?: Record<string, any> | undefined; params?: Record<...' is not assignable to type 'Endpoint'. Type '{ <C extends [{ body: { providerId: string; scopes?: string[] | undefined; callbackURL?: string | undefined; errorCallbackURL?: string | undefined; newUserCallbackURL?: string | undefined; disableRedirect?: boolean | undefined; }; method?: "POST" | undefined; query?: Record<string, any> | undefined; params?: Record<...' is not assignable to type '{ options: EndpointOptions; path: string; }'. The types of 'options.metadata.openapi.responses' are incompatible between these types. Type '{ 200: { description: string; content: { "application/json": { schema: { type: string; properties: { url: { type: string; }; redirect: { type: string; }; }; }; }; }; }; }' is not assignable to type '{ [status: string]: { description: string; content?: { "application/json"?: { schema: { type?: OpenAPISchemaType | undefined; properties?: Record<string, any> | undefined; required?: string[] | undefined; $ref?: string | undefined; }; } | undefined; "text/plain"?: { ...; } | undefined; "text/html"?: { ...; } | undef...'. Property '200' is incompatible with index signature. Type '{ description: string; content: { "application/json": { schema: { type: string; properties: { url: { type: string; }; redirect: { type: string; }; }; }; }; }; }' is not assignable to type '{ description: string; content?: { "application/json"?: { schema: { type?: OpenAPISchemaType | undefined; properties?: Record<string, any> | undefined; required?: string[] | undefined; $ref?: string | undefined; }; } | undefined; "text/plain"?: { ...; } | undefined; "text/html"?: { ...; } | undefined; } | undefined; }'. The types of 'content["application/json"].schema.type' are incompatible between these types. Type 'string' is not assignable to type 'OpenAPISchemaType | undefined'. 24 genericOAuth({ ~~~~~~~~~~~~~~ 25 config: [ ~~~~~~~~~~~~~~~ ... 52 ], ~~~~~~~~ 53 }), ~~~~~~ ```
Author
Owner

@ping-maxwell commented on GitHub (Feb 22, 2025):

@saevarb Maybe it's worth opening a new issue for this? Looks like it's a separate issue to sluggish ts performance.

<!-- gh-comment-id:2676298645 --> @ping-maxwell commented on GitHub (Feb 22, 2025): @saevarb Maybe it's worth opening a new issue for this? Looks like it's a separate issue to sluggish ts performance.
Author
Owner

@lakeesiv commented on GitHub (Feb 22, 2025):

@saevarb I am pretty sure it breaks all the plugins, as I am getting the Type 'string' is not assignable to type 'OpenAPISchemaType | undefined' for any plugin I use

<!-- gh-comment-id:2676421620 --> @lakeesiv commented on GitHub (Feb 22, 2025): @saevarb I am pretty sure it breaks all the plugins, as I am getting the `Type 'string' is not assignable to type 'OpenAPISchemaType | undefined'` for any plugin I use
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#8660