[PR #5701] [MERGED] fix: type mismatch for 'banned' on UserWithRole #6165

Closed
opened 2026-03-13 12:49:51 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/5701
Author: @GautamBytes
Created: 10/31/2025
Status: Merged
Merged: 10/31/2025
Merged by: @himself65

Base: canaryHead: fix/admin-user-type


📝 Commits (1)

  • b687fcd Fix UserWithRole banned type

📊 Changes

1 file changed (+1 additions, -1 deletions)

View changed files

📝 packages/better-auth/src/plugins/admin/types.ts (+1 -1)

📄 Description

Resolves: #4830

Description

This PR fixes a TypeScript type mismatch between the admin plugin's UserWithRole type and the client-side inferred type authClient.$Infer.Session.user.

The Problem

The UserWithRole interface in packages/better-auth/src/plugins/admin/types.ts incorrectly defined the banned property as optional:
banned?: (boolean | null) | undefined;

This conflicts with the client-side type inference, which correctly expects the field to always be present.

The Fix

This is a pure type-definition fix. The database adapters (like the Drizzle adapter) use db.select() (which is SELECT *), guaranteeing the banned field will always be returned as true, false, or null - but never undefined.

This PR corrects the type definition in types.ts to banned: boolean | null; to match the actual data returned by the adapter, resolving the type error. No runtime changes are necessary.


Summary by cubic

Make UserWithRole.banned a required boolean | null to match the client session user type and prevent TypeScript errors in the admin plugin. No runtime changes; this aligns with DB adapters that always return the field.

Written for commit b687fcd341. Summary will update automatically on new commits.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/better-auth/better-auth/pull/5701 **Author:** [@GautamBytes](https://github.com/GautamBytes) **Created:** 10/31/2025 **Status:** ✅ Merged **Merged:** 10/31/2025 **Merged by:** [@himself65](https://github.com/himself65) **Base:** `canary` ← **Head:** `fix/admin-user-type` --- ### 📝 Commits (1) - [`b687fcd`](https://github.com/better-auth/better-auth/commit/b687fcd341a8d0669d6412f3e98392ca1bc97566) Fix UserWithRole banned type ### 📊 Changes **1 file changed** (+1 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/plugins/admin/types.ts` (+1 -1) </details> ### 📄 Description **Resolves: #4830** ### Description This PR fixes a TypeScript type mismatch between the `admin` plugin's `UserWithRole` type and the client-side inferred type `authClient.$Infer.Session.user`. ### The Problem The `UserWithRole` interface in `packages/better-auth/src/plugins/admin/types.ts` incorrectly defined the `banned` property as optional: `banned?: (boolean | null) | undefined;` This conflicts with the client-side type inference, which correctly expects the field to always be present. ### The Fix This is a pure type-definition fix. The database adapters (like the Drizzle adapter) use `db.select()` (which is `SELECT *`), guaranteeing the `banned` field will always be returned as `true`, `false`, or `null` - but **never** `undefined`. This PR corrects the type definition in `types.ts` to `banned: boolean | null;` to match the actual data returned by the adapter, resolving the type error. No runtime changes are necessary. <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Make UserWithRole.banned a required boolean | null to match the client session user type and prevent TypeScript errors in the admin plugin. No runtime changes; this aligns with DB adapters that always return the field. <sup>Written for commit b687fcd341a8d0669d6412f3e98392ca1bc97566. Summary will update automatically on new commits.</sup> <!-- End of auto-generated description by cubic. --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-03-13 12:49:51 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#6165