Skip to content

fix(rest): type update.buildHeaders params with UpdateParams<any>#7456

Open
yashs33244 wants to merge 1 commit into
refinedev:mainfrom
yashs33244:fix/rest-update-buildheaders-variables-type
Open

fix(rest): type update.buildHeaders params with UpdateParams<any>#7456
yashs33244 wants to merge 1 commit into
refinedev:mainfrom
yashs33244:fix/rest-update-buildheaders-variables-type

Conversation

@yashs33244

Copy link
Copy Markdown

Summary

In @refinedev/rest, UpdateParams<TVariables = {}> defaults to {}. The update.buildHeaders option was typed BuildHeaders<UpdateParams> (no type arg), so a consumer's custom update.buildHeaders saw params.variables as {} and couldn't read any field off it without a TypeScript error.

This was the single outlier: all 9 other buildHeaders declarations, every other update option, and the default implementation use <any>. Sibling update.buildBodyParams / transformError already worked; only update.buildHeaders was affected.

Changes

  • packages/rest/src/types.ts: BuildHeaders<UpdateParams>BuildHeaders<UpdateParams<any>>
  • Add a custom buildHeaders test in update.spec.ts (reads params.variables.foo, asserts the derived header) + a patch changeset

Testing

  • Red-green proven against the real @refinedev/core types: reverting the line makes update.spec.ts fail with TS2339: Property 'foo' does not exist on type '{}'
  • biome ci clean; full @refinedev/rest vitest suite 90 tests pass

The update.buildHeaders option in createDataProvider was typed as
BuildHeaders<UpdateParams>, which resolves variables to the default {}
instead of any. Every other update option (getEndpoint, buildQueryParams,
buildBodyParams, mapResponse, transformError) and the default implementation
use UpdateParams<any>, so a custom update.buildHeaders callback could not read
fields off params.variables without a type error. Align the type with the rest
of the update options and add a test that derives a header from params.variables.
Copilot AI review requested due to automatic review settings June 15, 2026 03:59
@changeset-bot

changeset-bot Bot commented Jun 15, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 00e70e4

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

This PR includes changesets to release 1 package
Name Type
@refinedev/rest 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

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

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.

2 participants