Skip to content

fix: Typing when explicitly setting sideEffect in RestEndpoint#3726

Merged
ntucker merged 1 commit intomasterfrom
side-effect-typing
Feb 12, 2026
Merged

fix: Typing when explicitly setting sideEffect in RestEndpoint#3726
ntucker merged 1 commit intomasterfrom
side-effect-typing

Conversation

@ntucker
Copy link
Collaborator

@ntucker ntucker commented Feb 12, 2026

Motivation

When using sideEffect: false with method: 'POST' on a RestEndpoint (e.g., JSON-RPC or
POST-based search endpoints), the sideEffect type resolved to never instead of false.
This caused type information to be completely lost — both true and false were assignable
to sideEffect, and the type didn't persist through .extend() chains.

The docs already state that explicit sideEffect overrides method inference, but the types
didn't implement this correctly.

Solution

Replace Extract<O['sideEffect'], undefined | true> with Extract<O['sideEffect'], boolean | undefined> across all 6 locations in RestEndpointTypes.ts where the sideEffect type parameter is computed.

The original Extract<..., undefined | true> filtered out false because false is not in
undefined | true, causing Extract<false, undefined | true> = never. Widening to
boolean | undefined preserves all valid sideEffect values (false, true, undefined)
while still satisfying the M extends boolean | undefined constraint.

Additionally, RestExtendedEndpoint was missing a sideEffect priority check entirely — it
only checked method. Added the same sideEffect > method > inherited priority chain used
everywhere else.


Note

Low Risk
Type-only changes to RestEndpoint generics plus added TS tests; no runtime behavior changes, with the main risk being downstream compile-time type differences.

Overview
Ensures RestEndpoint type inference respects explicit sideEffect values (including false) over method-based inference, fixing cases where sideEffect: false with method: 'POST' previously collapsed to never (and could be lost through .extend()).

Adds TypeScript regression tests covering constructor/extend()/chained extend() scenarios, plus a patch changeset and a release-note entry documenting the fix.

Written by Cursor Bugbot for commit 592ba96. This will update automatically on new commits. Configure here.

@changeset-bot
Copy link

changeset-bot bot commented Feb 12, 2026

🦋 Changeset detected

Latest commit: 592ba96

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

This PR includes changesets to release 3 packages
Name Type
@data-client/rest Patch
test-bundlesize Patch
coinbase-lite 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

@github-actions
Copy link
Contributor

Size Change: 0 B

Total Size: 79.8 kB

ℹ️ View Unchanged
Filename Size
examples/test-bundlesize/dist/App.js 3.42 kB
examples/test-bundlesize/dist/polyfill.js 308 B
examples/test-bundlesize/dist/rdcClient.js 10.2 kB
examples/test-bundlesize/dist/rdcEndpoint.js 5.84 kB
examples/test-bundlesize/dist/react.js 59.4 kB
examples/test-bundlesize/dist/webpack-runtime.js 726 B

compressed-size-action

@codecov
Copy link

codecov bot commented Feb 12, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.13%. Comparing base (9aa648d) to head (592ba96).
⚠️ Report is 2 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #3726   +/-   ##
=======================================
  Coverage   98.13%   98.13%           
=======================================
  Files         150      150           
  Lines        2736     2736           
  Branches      537      537           
=======================================
  Hits         2685     2685           
  Misses         11       11           
  Partials       40       40           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@ntucker ntucker merged commit 9d94eb4 into master Feb 12, 2026
24 checks passed
@ntucker ntucker deleted the side-effect-typing branch February 12, 2026 14:20
@github-actions github-actions bot mentioned this pull request Feb 12, 2026
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.

1 participant