[GH-ISSUE #1323] [bug] Property 'data' does not exist #8692

Closed
opened 2026-04-13 03:51:14 -05:00 by GiteaMirror · 2 comments
Owner

Originally created by @draylegend on GitHub (Jan 31, 2025).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/1323

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

I'm using authClient in an angular app. I did read typescript's concepts, but still getting the error:

✘ [ERROR] TS2339: Property 'data' does not exist on type '{ data: { user: { id: string; email: string; emailVerified: boolean; name: string; createdAt: Date; updatedAt: Date; image?: string | null | undefined; twoFactorEnabled: boolean | null | undefined; }; session: { ...; }; } | null; error: BetterFetchError | null; isPending: boolean; } | undefined'. [plugin angular-compiler]

Image

auth.service.ts

import { computed, DestroyRef, Injectable, signal } from '@angular/core';
import { createAuthClient } from 'better-auth/client';
import {
  multiSessionClient,
  passkeyClient,
  twoFactorClient,
} from 'better-auth/client/plugins';

export const {
  signIn: { social },
  useSession,
} = createAuthClient({
  plugins: [multiSessionClient(), passkeyClient(), twoFactorClient()],
});

@Injectable({ providedIn: 'root' })
export class AuthService {
  session = computed(({ data } = this.#session()) => data);
  #session = signal<(typeof useSession)['value']>(undefined);

  constructor(ref: DestroyRef) {
    const unsub = useSession.subscribe(v => this.#session.set(v));
    ref.onDestroy(() => unsub());
  }
}

Current vs. Expected behavior

I'm expecting data to be destructable

What version of Better Auth are you using?

1.1.15

Provide environment information

wsl debian
bun 1.2.0

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

Client

Auth config (if applicable)

import { PrismaClient } from '@prisma/client';
import { betterAuth } from 'better-auth';
import { prismaAdapter } from 'better-auth/adapters/prisma';
import { multiSession, organization, twoFactor } from 'better-auth/plugins';
import { passkey } from 'better-auth/plugins/passkey';

const p = new PrismaClient();

export const auth = betterAuth({
  database: prismaAdapter(p, { provider: 'postgresql' }),
  emailAndPassword: { enabled: true },
  plugins: [multiSession(), organization(), passkey(), twoFactor()],
  socialProviders: {
    google: {
      clientId: `${process.env['GOOGLE_CLIENT_ID']}`,
      clientSecret: `${process.env['GOOGLE_CLIENT_SECRET']}`,
      redirectURI: `${process.env['BETTER_AUTH_URL']}/api/auth/callback/google`,
    },
  },
});

export type SocialProviders = keyof typeof auth.options.socialProviders;

Additional context

No response

Originally created by @draylegend on GitHub (Jan 31, 2025). Original GitHub issue: https://github.com/better-auth/better-auth/issues/1323 ### Is this suited for github? - [x] Yes, this is suited for github ### To Reproduce I'm using authClient in an angular app. I did read [typescript's concepts](https://www.better-auth.com/docs/concepts/typescript), but still getting the error: ```js ✘ [ERROR] TS2339: Property 'data' does not exist on type '{ data: { user: { id: string; email: string; emailVerified: boolean; name: string; createdAt: Date; updatedAt: Date; image?: string | null | undefined; twoFactorEnabled: boolean | null | undefined; }; session: { ...; }; } | null; error: BetterFetchError | null; isPending: boolean; } | undefined'. [plugin angular-compiler] ``` ![Image](https://github.com/user-attachments/assets/96485fad-d491-48c6-bbcc-f4758fd0c903) auth.service.ts ```ts import { computed, DestroyRef, Injectable, signal } from '@angular/core'; import { createAuthClient } from 'better-auth/client'; import { multiSessionClient, passkeyClient, twoFactorClient, } from 'better-auth/client/plugins'; export const { signIn: { social }, useSession, } = createAuthClient({ plugins: [multiSessionClient(), passkeyClient(), twoFactorClient()], }); @Injectable({ providedIn: 'root' }) export class AuthService { session = computed(({ data } = this.#session()) => data); #session = signal<(typeof useSession)['value']>(undefined); constructor(ref: DestroyRef) { const unsub = useSession.subscribe(v => this.#session.set(v)); ref.onDestroy(() => unsub()); } } ``` ### Current vs. Expected behavior I'm expecting data to be destructable ### What version of Better Auth are you using? 1.1.15 ### Provide environment information ```bash wsl debian bun 1.2.0 ``` ### Which area(s) are affected? (Select all that apply) Client ### Auth config (if applicable) ```typescript import { PrismaClient } from '@prisma/client'; import { betterAuth } from 'better-auth'; import { prismaAdapter } from 'better-auth/adapters/prisma'; import { multiSession, organization, twoFactor } from 'better-auth/plugins'; import { passkey } from 'better-auth/plugins/passkey'; const p = new PrismaClient(); export const auth = betterAuth({ database: prismaAdapter(p, { provider: 'postgresql' }), emailAndPassword: { enabled: true }, plugins: [multiSession(), organization(), passkey(), twoFactor()], socialProviders: { google: { clientId: `${process.env['GOOGLE_CLIENT_ID']}`, clientSecret: `${process.env['GOOGLE_CLIENT_SECRET']}`, redirectURI: `${process.env['BETTER_AUTH_URL']}/api/auth/callback/google`, }, }, }); export type SocialProviders = keyof typeof auth.options.socialProviders; ``` ### Additional context _No response_
GiteaMirror added the lockedbug labels 2026-04-13 03:51:15 -05:00
Author
Owner

@draylegend commented on GitHub (Mar 25, 2025):

Image

<!-- gh-comment-id:2751135307 --> @draylegend commented on GitHub (Mar 25, 2025): ![Image](https://github.com/user-attachments/assets/a3239280-4866-4343-a3d3-b74aaa114d8a)
Author
Owner

@Bekacru commented on GitHub (Jun 16, 2025):

useSession returns different based on where the client is imported from. By default it returns a nanostore atom object.

<!-- gh-comment-id:2975288106 --> @Bekacru commented on GitHub (Jun 16, 2025): `useSession` returns different based on where the client is imported from. By default it returns a nanostore atom object.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#8692