fix: access control indexing type#8155
Merged
himself65 merged 2 commits intobetter-auth:canaryfrom Mar 3, 2026
Merged
Conversation
|
@YevheniiKotyrlo is attempting to deploy a commit to the better-auth Team on Vercel. A member of the Team first needs to authorize it. |
@better-auth/api-key
better-auth
auth
@better-auth/core
@better-auth/drizzle-adapter
@better-auth/electron
@better-auth/expo
@better-auth/i18n
@better-auth/kysely-adapter
@better-auth/memory-adapter
@better-auth/mongo-adapter
@better-auth/oauth-provider
@better-auth/passkey
@better-auth/prisma-adapter
@better-auth/redis-storage
@better-auth/scim
@better-auth/sso
@better-auth/stripe
@better-auth/telemetry
@better-auth/test-utils
commit: |
Two source-level type fixes: 1. Remove `export type * from "zod/v4/core"` from src/index.ts. The line already has @ts-expect-error and the re-export overlaps with `export type * from "zod/v4"`, leaking internal types that cause TS2742 "cannot be named" errors for consumers with skipLibCheck: false. 2. Replace S[key][number] with ArrayElement<S[key]> in access control types. TypeScript cannot narrow the intermediate [key] access to readonly unknown[] after the conditional check, causing type errors in emitted .d.ts for admin and organization plugin permission types.
52416f9 to
8e062fc
Compare
himself65
added a commit
that referenced
this pull request
Mar 3, 2026
Co-authored-by: Alex Yang <himself65@outlook.com>
5 tasks
himself65
added a commit
that referenced
this pull request
Mar 3, 2026
Co-authored-by: Alex Yang <himself65@outlook.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two source-level type fixes for consumers with
skipLibCheck: false:1. Remove
zod/v4/corere-export fromsrc/index.tsThe line
export type * from "zod/v4/core"overlaps withexport type * from "zod/v4"and leaks internal Zod types into the public API namespace. This causes TS2742 ("cannot be named without a reference to zod/v4/core") for consumers. The line already has@ts-expect-errorabove it, confirming it was known to be problematic.Related: #5574, #4837
2. Fix access control
[key][number]indexing in admin and organization pluginsThe emitted
.d.tsfor permission types usesS[key][number]double-indexing, but TypeScript cannot narrow the intermediate[key]access toreadonly unknown[]after the conditional check. This produces type errors in the emitted declarations for both admin and organization plugin client types.Fix: introduce an
ArrayElement<T>helper type (T extends readonly (infer E)[] ? E : never) and useArrayElement<S[key]>instead ofS[key][number]in 4 locations (admin/client.ts, admin/routes.ts, organization/client.ts, organization/organization.ts).Related: #4804, #6491, #6127
Impact
pnpm typecheck,pnpm lint,pnpm buildall passskipLibCheck: falseVerification
pnpm typecheck— zero errorspnpm lint(Biome, 1386 files) — no issuespnpm build(tsdown, 673 output files) — clean in ~1100msSummary by cubic
Fix TypeScript declaration issues by removing the zod/v4/core type re-export and using a new ArrayElement helper for permission arrays. This resolves TS2742 and permission type errors for projects using skipLibCheck: false.
Written for commit e0036d5. Summary will update on new commits.