mirror of
https://github.com/better-auth/better-auth.git
synced 2026-08-28 14:45:40 -05:00
fix(client): a client with more plugins fits a narrower client type again (#10907)
Co-authored-by: Taesu <bytaesu@gmail.com>
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"better-auth": patch
|
||||
---
|
||||
|
||||
A client created with more plugins is again assignable to a client type declaring fewer plugins, as in 1.6.
|
||||
@@ -17,6 +17,7 @@ import {
|
||||
organizationClient,
|
||||
twoFactorClient,
|
||||
} from "./plugins";
|
||||
import type { ReactAuthClient } from "./react";
|
||||
import { createAuthClient as createReactClient } from "./react";
|
||||
import { createAuthClient as createSolidClient } from "./solid";
|
||||
import { createAuthClient as createSvelteClient } from "./svelte";
|
||||
@@ -419,6 +420,19 @@ describe("run time proxy", async () => {
|
||||
});
|
||||
|
||||
describe("type", () => {
|
||||
/**
|
||||
* @see https://github.com/better-auth/better-auth/issues/10897
|
||||
*/
|
||||
it("keeps a client with more plugins assignable to a client type with fewer plugins", () => {
|
||||
type EmailOtpClient = ReactAuthClient<{
|
||||
plugins: [ReturnType<typeof emailOTPClient>];
|
||||
}>;
|
||||
const client = createReactClient({
|
||||
plugins: [emailOTPClient(), adminClient()],
|
||||
});
|
||||
expectTypeOf(client).toMatchTypeOf<EmailOtpClient>();
|
||||
});
|
||||
|
||||
it("should not infer non-action endpoints", () => {
|
||||
const client = createReactClient({
|
||||
plugins: [testClientPlugin()],
|
||||
|
||||
@@ -60,9 +60,7 @@ export type LynxAuthClient<Option extends BetterAuthClientOptions> =
|
||||
UnionToIntersection<InferResolvedHooks<Option>> &
|
||||
InferClientAPI<Option> &
|
||||
InferActions<Option> & {
|
||||
hydrateSession: (
|
||||
session: NonNullable<ClientSession<Option>> | null,
|
||||
) => void;
|
||||
hydrateSession(session: NonNullable<ClientSession<Option>> | null): void;
|
||||
useSession: () => {
|
||||
data: ClientSession<Option>;
|
||||
isPending: boolean;
|
||||
|
||||
@@ -60,9 +60,7 @@ export type ReactAuthClient<Option extends BetterAuthClientOptions> =
|
||||
UnionToIntersection<InferResolvedHooks<Option>> &
|
||||
InferClientAPI<Option> &
|
||||
InferActions<Option> & {
|
||||
hydrateSession: (
|
||||
session: NonNullable<ClientSession<Option>> | null,
|
||||
) => void;
|
||||
hydrateSession(session: NonNullable<ClientSession<Option>> | null): void;
|
||||
useSession: () => {
|
||||
data: ClientSession<Option>;
|
||||
isPending: boolean;
|
||||
|
||||
@@ -61,9 +61,7 @@ export type SolidAuthClient<Option extends BetterAuthClientOptions> =
|
||||
UnionToIntersection<InferResolvedHooks<Option>> &
|
||||
InferClientAPI<Option> &
|
||||
InferActions<Option> & {
|
||||
hydrateSession: (
|
||||
session: NonNullable<ClientSession<Option>> | null,
|
||||
) => void;
|
||||
hydrateSession(session: NonNullable<ClientSession<Option>> | null): void;
|
||||
useSession: () => Accessor<{
|
||||
data: ClientSession<Option>;
|
||||
isPending: boolean;
|
||||
|
||||
@@ -56,9 +56,7 @@ export type SvelteAuthClient<Option extends BetterAuthClientOptions> =
|
||||
UnionToIntersection<InferResolvedHooks<Option>> &
|
||||
InferClientAPI<Option> &
|
||||
InferActions<Option> & {
|
||||
hydrateSession: (
|
||||
session: NonNullable<ClientSession<Option>> | null,
|
||||
) => void;
|
||||
hydrateSession(session: NonNullable<ClientSession<Option>> | null): void;
|
||||
useSession: () => Atom<{
|
||||
data: ClientSession<Option>;
|
||||
error: BetterFetchError | null;
|
||||
|
||||
@@ -56,9 +56,7 @@ export type AuthClient<Option extends BetterAuthClientOptions> =
|
||||
UnionToIntersection<InferResolvedHooks<Option>> &
|
||||
InferClientAPI<Option> &
|
||||
InferActions<Option> & {
|
||||
hydrateSession: (
|
||||
session: NonNullable<ClientSession<Option>> | null,
|
||||
) => void;
|
||||
hydrateSession(session: NonNullable<ClientSession<Option>> | null): void;
|
||||
useSession: Atom<{
|
||||
data: ClientSession<Option>;
|
||||
error: BetterFetchError | null;
|
||||
|
||||
@@ -88,9 +88,7 @@ export type VueAuthClient<Option extends BetterAuthClientOptions> =
|
||||
UnionToIntersection<InferResolvedHooks<Option>> &
|
||||
InferClientAPI<Option> &
|
||||
InferActions<Option> & {
|
||||
hydrateSession: (
|
||||
session: NonNullable<ClientSession<Option>> | null,
|
||||
) => void;
|
||||
hydrateSession(session: NonNullable<ClientSession<Option>> | null): void;
|
||||
useSession: VueUseSession<Option>;
|
||||
$Infer: {
|
||||
Session: NonNullable<ClientSession<Option>>;
|
||||
|
||||
Reference in New Issue
Block a user