[GH-ISSUE #5625] Not getting types despite using inferAdditionalFields plugin in expo #27629

Closed
opened 2026-04-17 18:44:13 -05:00 by GiteaMirror · 3 comments
Owner

Originally created by @mahabubsaki on GitHub (Oct 27, 2025).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/5625

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

Use inferAdditionalFields plugin in expo client

Current vs. Expected behavior

Image

Current : I need some extra field in my user object, so I added those on server. But in expo client despite infering I am not getting the types. I used the same plugin in web client and got proper types

Expected behavior: I should get the types properly like web

What version of Better Auth are you using?

1.3.26

System info

{
  "system": {
    "platform": "win32",        
    "arch": "x64",
    "version": "Windows 10 Pro",
    "release": "10.0.19045",    
    "cpuCount": 12,
    "cpuModel": "AMD Ryzen 5 5600G with Radeon Graphics         ",
    "totalMemory": "19.90 GB",
    "freeMemory": "2.32 GB"
  },
  "node": {
    "version": "v22.19.0",
    "env": "development"
  },
  "packageManager": {
    "name": "pnpm",
    "version": "10.5.2"
  },
  "frameworks": [
    {
      "name": "react",
      "version": "19.1.0"
    }
  ],
  "databases": null,
  "betterAuth": {
    "version": "^1.3.26",
    "config": null
  }
}

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

Client

Auth config (if applicable)

import { betterAuth } from "better-auth"
export const auth = betterAuth({
  emailAndPassword: {  
    enabled: true
  },
});

Additional context

No response

Originally created by @mahabubsaki on GitHub (Oct 27, 2025). Original GitHub issue: https://github.com/better-auth/better-auth/issues/5625 ### Is this suited for github? - [x] Yes, this is suited for github ### To Reproduce Use inferAdditionalFields plugin in expo client ### Current vs. Expected behavior <img width="1679" height="1156" alt="Image" src="https://github.com/user-attachments/assets/8c557964-89b9-4995-8b3d-6e38c18e0ef7" /> Current : I need some extra field in my user object, so I added those on server. But in expo client despite infering I am not getting the types. I used the same plugin in web client and got proper types Expected behavior: I should get the types properly like web ### What version of Better Auth are you using? 1.3.26 ### System info ```bash { "system": { "platform": "win32", "arch": "x64", "version": "Windows 10 Pro", "release": "10.0.19045", "cpuCount": 12, "cpuModel": "AMD Ryzen 5 5600G with Radeon Graphics ", "totalMemory": "19.90 GB", "freeMemory": "2.32 GB" }, "node": { "version": "v22.19.0", "env": "development" }, "packageManager": { "name": "pnpm", "version": "10.5.2" }, "frameworks": [ { "name": "react", "version": "19.1.0" } ], "databases": null, "betterAuth": { "version": "^1.3.26", "config": null } } ``` ### Which area(s) are affected? (Select all that apply) Client ### Auth config (if applicable) ```typescript import { betterAuth } from "better-auth" export const auth = betterAuth({ emailAndPassword: { enabled: true }, }); ``` ### Additional context _No response_
GiteaMirror added the locked label 2026-04-17 18:44:13 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Oct 27, 2025):

Type inference for additional user fields with inferAdditionalFields relies on your client having access to the server's type definitions. In monorepos or when the client and server share types, you should import your auth instance type from the server and use inferAdditionalFields<typeof auth>() in your Expo client setup. This ensures TypeScript can infer the extra fields as expected (reference).

If your Expo client is in a separate project and can't import the server's auth type, you'll need to manually define the additional fields in the client for type inference to work.

Also, make sure your tsconfig.json is set up for modern module resolution ("moduleResolution": "nodenext" or "bundler") and that "exactOptionalPropertyTypes" is set to false, as strict settings here can break plugin field inference (reference).

If you already share types and have the correct config but still don't get types in Expo, try clearing your build cache and node_modules—sometimes stale or mismatched versions can cause type inference to silently fail (reference).

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other  Chat with Dosu Join Discord Share on X

<!-- gh-comment-id:3453517193 --> @dosubot[bot] commented on GitHub (Oct 27, 2025): <!-- Answer --> Type inference for additional user fields with `inferAdditionalFields` relies on your client having access to the server's type definitions. In monorepos or when the client and server share types, you should import your `auth` instance type from the server and use `inferAdditionalFields<typeof auth>()` in your Expo client setup. This ensures TypeScript can infer the extra fields as expected ([reference](https://github.com/better-auth/better-auth/discussions/5302#discussioncomment-14677114)). If your Expo client is in a separate project and can't import the server's `auth` type, you'll need to manually define the additional fields in the client for type inference to work. Also, make sure your `tsconfig.json` is set up for modern module resolution (`"moduleResolution": "nodenext"` or `"bundler"`) and that `"exactOptionalPropertyTypes"` is set to `false`, as strict settings here can break plugin field inference ([reference](https://github.com/better-auth/better-auth/issues/5538)). If you already share types and have the correct config but still don't get types in Expo, try clearing your build cache and node_modules—sometimes stale or mismatched versions can cause type inference to silently fail ([reference](https://github.com/better-auth/better-auth/issues/512)). <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/1358e7f6-c6a7-47dc-8432-37c39a9d1c18?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/1358e7f6-c6a7-47dc-8432-37c39a9d1c18?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/1358e7f6-c6a7-47dc-8432-37c39a9d1c18?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/1358e7f6-c6a7-47dc-8432-37c39a9d1c18?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/1358e7f6-c6a7-47dc-8432-37c39a9d1c18?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/1358e7f6-c6a7-47dc-8432-37c39a9d1c18?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/1358e7f6-c6a7-47dc-8432-37c39a9d1c18?feedback_type=other)</sup>&nbsp;&nbsp;[![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/cdda13d9-dd27-4d31-b09a-5d8bec92de21/ask?utm_source=github)&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/better-auth/better-auth/issues/5625)
Author
Owner

@Bekacru commented on GitHub (Oct 28, 2025):

I couldn't reproduce this on my end. Can you send me your tsconfig?

<!-- gh-comment-id:3454255330 --> @Bekacru commented on GitHub (Oct 28, 2025): I couldn't reproduce this on my end. Can you send me your tsconfig?
Author
Owner

@mahabubsaki commented on GitHub (Oct 28, 2025):

I couldn't reproduce this on my end. Can you send me your tsconfig?

I imported auth type from my server and the issue was fixed🤔. Maybe this is the right way instead of manually adding the types

<!-- gh-comment-id:3455494598 --> @mahabubsaki commented on GitHub (Oct 28, 2025): > I couldn't reproduce this on my end. Can you send me your tsconfig? I imported auth type from my server and the issue was fixed🤔. Maybe this is the right way instead of manually adding the types
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#27629