[PR #7471] [MERGED] chore: remove unnecessary type castings #7336

Closed
opened 2026-03-13 13:32:34 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/7471
Author: @bytaesu
Created: 1/19/2026
Status: Merged
Merged: 1/20/2026
Merged by: @himself65

Base: canaryHead: cursor/unnecessary-type-castings-1c35


📝 Commits (4)

  • 76d8d77 fix: remove unnecessary type castings with as "..."
  • 4e41291 fix: remove unnecessary as "value" cast in expo client
  • 61cd332 Merge branch 'canary' into cursor/unnecessary-type-castings-1c35
  • 1ff3ffa fix: remove unnecessary type casting

📊 Changes

4 files changed (+9 additions, -9 deletions)

View changed files

📝 packages/better-auth/src/cookies/index.ts (+2 -3)
📝 packages/better-auth/src/plugins/open-api/index.ts (+1 -1)
📝 packages/better-auth/src/plugins/organization/organization.test.ts (+4 -4)
📝 packages/expo/src/client.ts (+2 -1)

📄 Description

Remove unnecessary type castings to improve type correctness and remove redundancy.

The role as "owner" cast in organization.test.ts was semantically incorrect, forcing all roles to "owner". This was fixed by removing the cast and adding as const to the test data array, allowing TypeScript to correctly infer the union type of roles ("owner" | "admin" | "member"). The as "/reference" cast was removed as it was redundant due to the default value already providing the correct type.


Slack Thread

Open in Cursor Open in Web


Summary by cubic

Removed unnecessary type casts to improve type safety and correctness. Fixes cookie attribute parsing and corrects organization invite test roles.

  • Bug Fixes

    • Expo client: parseSetCookieHeader now stores attributes by their actual names (adds index signature, removes "value" cast).
  • Refactors

    • Cookies: removed cast to "session_token"; use dynamic cookie keys and default attributes to {}.
    • OpenAPI: removed redundant cast on default path "/reference".
    • Organization tests: removed forced "owner" cast; roles marked as const to infer "owner" | "admin" | "member".

Written for commit 1ff3ffa0ac. Summary will update 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/7471 **Author:** [@bytaesu](https://github.com/bytaesu) **Created:** 1/19/2026 **Status:** ✅ Merged **Merged:** 1/20/2026 **Merged by:** [@himself65](https://github.com/himself65) **Base:** `canary` ← **Head:** `cursor/unnecessary-type-castings-1c35` --- ### 📝 Commits (4) - [`76d8d77`](https://github.com/better-auth/better-auth/commit/76d8d77a778b244d4646fef1c51e61f66064cb32) fix: remove unnecessary type castings with `as "..."` - [`4e41291`](https://github.com/better-auth/better-auth/commit/4e4129102e5ba58077e1af1f7395d33cc9aeacbc) fix: remove unnecessary `as "value"` cast in expo client - [`61cd332`](https://github.com/better-auth/better-auth/commit/61cd3320c338f9889c85a0da03db2dbb1bb5c35f) Merge branch 'canary' into cursor/unnecessary-type-castings-1c35 - [`1ff3ffa`](https://github.com/better-auth/better-auth/commit/1ff3ffa0ac386d9e0ed19ffbd74a1625d1c4f05b) fix: remove unnecessary type casting ### 📊 Changes **4 files changed** (+9 additions, -9 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/cookies/index.ts` (+2 -3) 📝 `packages/better-auth/src/plugins/open-api/index.ts` (+1 -1) 📝 `packages/better-auth/src/plugins/organization/organization.test.ts` (+4 -4) 📝 `packages/expo/src/client.ts` (+2 -1) </details> ### 📄 Description Remove unnecessary type castings to improve type correctness and remove redundancy. The `role as "owner"` cast in `organization.test.ts` was semantically incorrect, forcing all roles to `"owner"`. This was fixed by removing the cast and adding `as const` to the test data array, allowing TypeScript to correctly infer the union type of roles (`"owner" | "admin" | "member"`). The `as "/reference"` cast was removed as it was redundant due to the default value already providing the correct type. --- [Slack Thread](https://betterauth.slack.com/archives/C0A8B5BARUK/p1768848614668359?thread_ts=1768848614.668359&cid=C0A8B5BARUK) <a href="https://cursor.com/background-agent?bcId=bc-d0843960-96b6-4bc1-a1d5-e75eba781ddf"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/open-in-cursor-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/open-in-cursor-light.svg"><img alt="Open in Cursor" src="https://cursor.com/open-in-cursor.svg"></picture></a>&nbsp;<a href="https://cursor.com/agents?id=bc-d0843960-96b6-4bc1-a1d5-e75eba781ddf"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/open-in-web-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/open-in-web-light.svg"><img alt="Open in Web" src="https://cursor.com/open-in-web.svg"></picture></a> <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Removed unnecessary type casts to improve type safety and correctness. Fixes cookie attribute parsing and corrects organization invite test roles. - **Bug Fixes** - Expo client: parseSetCookieHeader now stores attributes by their actual names (adds index signature, removes "value" cast). - **Refactors** - Cookies: removed cast to "session_token"; use dynamic cookie keys and default attributes to {}. - OpenAPI: removed redundant cast on default path "/reference". - Organization tests: removed forced "owner" cast; roles marked as const to infer "owner" | "admin" | "member". <sup>Written for commit 1ff3ffa0ac386d9e0ed19ffbd74a1625d1c4f05b. Summary will update 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 13:32:35 -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#7336