diff --git a/e2e/smoke/test/fixtures/tsconfig-exact-optional-property-types/package.json b/e2e/smoke/test/fixtures/tsconfig-exact-optional-property-types/package.json new file mode 100644 index 0000000000..ec3f2c4e0e --- /dev/null +++ b/e2e/smoke/test/fixtures/tsconfig-exact-optional-property-types/package.json @@ -0,0 +1,12 @@ +{ + "name": "tsconfig-exact-optional-property-types", + "private": true, + "type": "module", + "scripts": { + "typecheck": "tsc --project tsconfig.json" + }, + "dependencies": { + "better-auth": "workspace:*", + "better-sqlite3": "^12.4.1" + } +} diff --git a/e2e/smoke/test/fixtures/tsconfig-exact-optional-property-types/src/index.ts b/e2e/smoke/test/fixtures/tsconfig-exact-optional-property-types/src/index.ts new file mode 100644 index 0000000000..5bf8cdf8ec --- /dev/null +++ b/e2e/smoke/test/fixtures/tsconfig-exact-optional-property-types/src/index.ts @@ -0,0 +1,28 @@ +import { betterAuth } from "better-auth"; +import { organization } from "better-auth/plugins"; +import { nextCookies } from "better-auth/next-js"; +import Database from "better-sqlite3"; +import { createAuthClient } from "better-auth/react"; +import { + inferAdditionalFields, + organizationClient, +} from "better-auth/client/plugins"; + +const auth = betterAuth({ + database: new Database("./sqlite.db"), + trustedOrigins: [], + emailAndPassword: { + enabled: true, + }, + plugins: [organization(), nextCookies()], + user: { + additionalFields: {}, + }, +}); +const authClient = createAuthClient({ + baseURL: "http://localhost:3000", + plugins: [inferAdditionalFields(), organizationClient()], +}); + +authClient.useActiveOrganization(); +authClient.useSession(); diff --git a/e2e/smoke/test/fixtures/tsconfig-exact-optional-property-types/tsconfig.json b/e2e/smoke/test/fixtures/tsconfig-exact-optional-property-types/tsconfig.json new file mode 100644 index 0000000000..b5c61e1bf0 --- /dev/null +++ b/e2e/smoke/test/fixtures/tsconfig-exact-optional-property-types/tsconfig.json @@ -0,0 +1,14 @@ +{ + "compilerOptions": { + "target": "ESNext", + "module": "NodeNext", + "outDir": "dist", + "strict": true, + "exactOptionalPropertyTypes": true, + "skipLibCheck": true, + "types": ["node"], + "jsx": "react-jsx", + "jsxImportSource": "hono/jsx", + "moduleResolution": "node16" + } +} diff --git a/packages/better-auth/src/api/to-auth-endpoints.ts b/packages/better-auth/src/api/to-auth-endpoints.ts index e9fdb73db9..90dd0fb39b 100644 --- a/packages/better-auth/src/api/to-auth-endpoints.ts +++ b/packages/better-auth/src/api/to-auth-endpoints.ts @@ -11,8 +11,7 @@ import type { } from "@better-auth/core/middleware"; import { createDefu } from "defu"; import { shouldPublishLog } from "@better-auth/core/env"; -import type { AuthContext } from "@better-auth/core"; -import type { HookEndpointContext } from "../types"; +import type { AuthContext, HookEndpointContext } from "@better-auth/core"; type InternalContext = InputContext & EndpointContext & { diff --git a/packages/better-auth/src/client/lynx/index.ts b/packages/better-auth/src/client/lynx/index.ts index 2ad4d00743..075ad7ee08 100644 --- a/packages/better-auth/src/client/lynx/index.ts +++ b/packages/better-auth/src/client/lynx/index.ts @@ -27,22 +27,25 @@ export function capitalizeFirstLetter(str: string) { return str.charAt(0).toUpperCase() + str.slice(1); } -type InferResolvedHooks = - O["plugins"] extends Array - ? Plugin extends BetterAuthClientPlugin - ? Plugin["getAtoms"] extends (fetch: any) => infer Atoms - ? Atoms extends Record - ? { - [key in keyof Atoms as IsSignal extends true - ? never - : key extends string - ? `use${Capitalize}` - : never]: () => ReturnType; - } +type InferResolvedHooks = O extends { + plugins: Array; +} + ? UnionToIntersection< + Plugin extends BetterAuthClientPlugin + ? Plugin["getAtoms"] extends (fetch: any) => infer Atoms + ? Atoms extends Record + ? { + [key in keyof Atoms as IsSignal extends true + ? never + : key extends string + ? `use${Capitalize}` + : never]: () => ReturnType; + } + : {} : {} : {} - : {} - : {}; + > + : {}; export function createAuthClient