Skip to content

fix(core): extend BaseKey to include number[] for UUID support#7453

Open
devavijha wants to merge 1 commit into
refinedev:mainfrom
devavijha:fix/base-key-uuid-support
Open

fix(core): extend BaseKey to include number[] for UUID support#7453
devavijha wants to merge 1 commit into
refinedev:mainfrom
devavijha:fix/base-key-uuid-support

Conversation

@devavijha

@devavijha devavijha commented Jun 12, 2026

Copy link
Copy Markdown

Problem

BaseKey is currently typed as string | number. Some OpenAPI code generators represent UUID fields as number[] (byte arrays) in TypeScript. Users working with such types must cast their ID values to satisfy the BaseKey constraint:

useOne({ resource: "orders", id: uuidBytes as unknown as string })

This defeats TypeScript safety and produces confusing code.

See: #7403

Fix

Extend BaseKey from string | number to string | number | number[].

The change is additive. All existing usage of string and number IDs is unaffected.

// Before: required an explicit cast
useOne({ resource: "orders", id: uuidBytes as unknown as string })

// After: works without a cast
useOne({ resource: "orders", id: uuidBytes })

Files changed

  • packages/core/src/contexts/data/types.ts — extends BaseKey union type
  • packages/core/src/hooks/navigation/index.ts — fixes three encodeURIComponent(id) call sites that TypeScript correctly flags after the type extension; number[] is converted to a comma-separated string before encoding

TypeScript verification

Ran tsc --noEmit on packages/core before and after the change. The only remaining error is a pre-existing test file path issue present on main as well.

Closes #7403

@changeset-bot

changeset-bot Bot commented Jun 12, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: f58324a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@refinedev/core Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Some OpenAPI generators produce TypeScript types where UUID fields are
represented as number[] (byte arrays). The current BaseKey union of
string | number did not cover this case, forcing users to cast their ID
values when passing them to refine hooks.

Extend BaseKey to string | number | number[]. The change is additive;
all existing usage of string and number IDs is unaffected.

Fixes refinedev#7403
@devavijha devavijha force-pushed the fix/base-key-uuid-support branch from d11814b to f58324a Compare June 12, 2026 04:39

@devavijha devavijha left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

look into this...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] BaseKey needs to support UUID

1 participant