[GH-ISSUE #7681] Passing a previously defined statement directly into ac.newRole causes TypeScript error #10869

Closed
opened 2026-04-13 07:14:15 -05:00 by GiteaMirror · 1 comment
Owner

Originally created by @longnguyen2004 on GitHub (Jan 29, 2026).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/7681

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

Reproduction

Current vs. Expected behavior

Current behavior: TypeScript error on ac.newRole
Expected behavior: No TypeScript error

What version of Better Auth are you using?

1.4.18

System info

{
  "system": {
    "platform": "win32",
    "arch": "x64",
    "version": "Windows 11 IoT Enterprise LTSC 2024",
    "release": "10.0.26100",
    "cpuCount": 12,
    "cpuModel": "AMD Ryzen 5 5600H with Radeon Graphics         ",
    "totalMemory": "15.36 GB",
    "freeMemory": "3.60 GB"
  },
  "node": {
    "version": "v24.11.1",
    "env": "development"
  },
  "packageManager": {
    "name": "npm",
    "version": "11.0.0"
  },
  "frameworks": null,
  "databases": null,
  "betterAuth": {
    "version": "^1.4.18",
    "config": null
  }
}

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

Types

Auth config (if applicable)


Additional context

No response

Originally created by @longnguyen2004 on GitHub (Jan 29, 2026). Original GitHub issue: https://github.com/better-auth/better-auth/issues/7681 ### Is this suited for github? - [x] Yes, this is suited for github ### To Reproduce [Reproduction](https://www.typescriptlang.org/play/?#code/JYWwDg9gTgLgBAbzgYygUwIYzQQWctAZ0IGEIA7GKCAGzgF84AzakOAIgCM0ZsoBaDAFcYACwD0YGkIDmwcoXEZ8RQuwDcAKFCRYiOABM0TYTRgBlGFjQg0lQg2asO3XmgHCxk6XIXjoMhjkwABeWMAUSirEGpqayBSE8EnWtpRwALyImnBwAHQFRiZCZpapdjCEADQ5cBgAXHAA2uwY7AC6NbmcjS2cHTWMGA4JCjBa8Ynwypko6NZ4BMRklNQ0ABQp2GkwAJQTo0lwEADu5O6zynnnJwBKtGibVtsV+5pAA) ### Current vs. Expected behavior Current behavior: TypeScript error on `ac.newRole` Expected behavior: No TypeScript error ### What version of Better Auth are you using? 1.4.18 ### System info ```bash { "system": { "platform": "win32", "arch": "x64", "version": "Windows 11 IoT Enterprise LTSC 2024", "release": "10.0.26100", "cpuCount": 12, "cpuModel": "AMD Ryzen 5 5600H with Radeon Graphics ", "totalMemory": "15.36 GB", "freeMemory": "3.60 GB" }, "node": { "version": "v24.11.1", "env": "development" }, "packageManager": { "name": "npm", "version": "11.0.0" }, "frameworks": null, "databases": null, "betterAuth": { "version": "^1.4.18", "config": null } } ``` ### Which area(s) are affected? (Select all that apply) Types ### Auth config (if applicable) ```typescript ``` ### Additional context _No response_
GiteaMirror added the locked label 2026-04-13 07:14:15 -05:00
Author
Owner

@better-auth-agent[bot] commented on GitHub (Jan 29, 2026):

It looks like you're encountering a TypeScript error when trying to pass a previously defined statement directly into ac.newRole. This is a known issue that can occur due to TypeScript's type inference limitations in certain scenarios.

From the available context, it would be beneficial to ensure that you provide exact types for your roles while defining them. Sometimes, using explicit type annotations can help resolve such issues. An example workaround mentioned is:

export const user = ac.newRole({
  ...userAc.statements,
} as Parameters<typeof ac.newRole>[0]);

If you continue to experience issues, or this doesn't resolve the problem, it may be worthwhile to share your specific code snippets with the Better Auth team for further assistance. You can tag Beka (@bekacru) or Max (@ping__) in your GitHub thread for their expertise.

Is there anything else you need help with regarding Better Auth or TypeScript integration?

If you need more help, tag @better-auth-agent in a comment so I can respond.

DiagramDiscordGitHub

Diagram Join Star

<!-- gh-comment-id:3816984583 --> @better-auth-agent[bot] commented on GitHub (Jan 29, 2026): It looks like you're encountering a TypeScript error when trying to pass a previously defined `statement` directly into `ac.newRole`. This is a known issue that can occur due to TypeScript's type inference limitations in certain scenarios. From the available context, it would be beneficial to ensure that you provide exact types for your roles while defining them. Sometimes, using explicit type annotations can help resolve such issues. An example workaround mentioned is: ```typescript export const user = ac.newRole({ ...userAc.statements, } as Parameters<typeof ac.newRole>[0]); ``` If you continue to experience issues, or this doesn't resolve the problem, it may be worthwhile to share your specific code snippets with the Better Auth team for further assistance. You can tag Beka (@bekacru) or Max (@ping__) in your GitHub thread for their expertise. Is there anything else you need help with regarding Better Auth or TypeScript integration? _If you need more help, tag @better-auth-agent in a comment so I can respond._ <!-- bot:webhook reply v1 --> [Diagram](https://repodiagrams.s3.eu-north-1.amazonaws.com/better-auth_ultra_detailed_interactive.html) • [Discord](https://discord.gg/better-auth) • [GitHub](https://github.com/better-auth/better-auth) [![Diagram](https://img.shields.io/badge/Diagram-2b3137?style=flat-square)](https://repodiagrams.s3.eu-north-1.amazonaws.com/better-auth_ultra_detailed_interactive.html) [![Join](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&style=flat-square)](https://discord.gg/better-auth) [![Star](https://img.shields.io/badge/star-181717?logo=github&logoColor=white&style=flat-square)](https://github.com/better-auth/better-auth)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#10869