Skip to content

fix: useDLE() types data for schema-less endpoints with nullable args - #4709

Merged
ntucker merged 3 commits into
masterfrom
claude/project-thread-y69pdb
Nov 20, 2026
Merged

ntucker merged 3 commits into
masterfrom
claude/project-thread-y69pdb

Conversation

@ntucker

@ntucker ntucker commented Nov 20, 2026 •

Copy link
Copy Markdown
Collaborator

Requested by Nathaniel · project thread

No website changes (only regenerated playground editor types).

Motivation

Bug fix.

An app calls useDLE() with an endpoint that has no schema, and passes args that can be null to skip the fetch.

In ntucker/chess, useDLE(getEvaluation, ...(cond ? ['stockfish', line] as const : [null])) typed data as undefined. The hook returns the resolved value at runtime, so the app could not read it without a cast. useSuspense() and useCache() type the same call as the resolved value or undefined.

Solution

The nullable-args overload of useDLE() now types data as ResolveType<E> | undefined when the endpoint has no schema, like useSuspense() and useCache(). This covers React (web and native) and Vue. No other hook overload had this mistake.

import { Endpoint } from '@data-client/endpoint';
import { useDLE } from '@data-client/react';

const getTitle = new Endpoint(async ({ id }: { id: number }) => ({
  id,
  title: 'hi',
}));

function Title({ id }: { id: number | null }) {
  const { data } = useDLE(getTitle, id === null ? null : { id });
  // Before: data is typed as undefined
  // After: data is typed as { id: number; title: string } | undefined
  return <h1>{data?.title}</h1>;
}

Internal: deletes the unused SuspenseReturn and CondNull types in packages/react/src/hooks/types.ts. Nothing imported them, and they still had the old undefined typing.

Assumptions and validation

  • New React and Vue tests use a schema-less Endpoint with nullable args. They check the type (data?.title is string | undefined, an unknown property is an error) and the runtime value. On the old types, both tests fail typecheck with Property 'title' does not exist on type 'never'. High certainty.
  • useDLE React and Vue suites pass (49 tests), with Jest's typecheck on. yarn build:types, lint and Prettier pass. yarn copy:websitetypes output is committed. High certainty.
  • Not breaking: data only widens from undefined. Code that relied on undefined exactly would be unusual. High certainty.
  • Did not run yarn test:coverage: no runtime code changed. Medium certainty that coverage is unchanged, since only types and tests changed.
  • The native overload has no dedicated type test: tsc resolves useDLE.ts first (moduleSuffixes: ["", ".native"]), so a native test would check the web file. It is the same one-line edit. Medium certainty.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Y5C5ZBtGvJe2W3ajt3TdxV


Note

Low Risk
Types-only widening of data with no runtime changes; risk is limited to stricter compile-time checks where code incorrectly assumed data could never hold a value.

Overview
Fixes useDLE() so that when an endpoint has no schema and args may be null (to skip fetching), data is typed as ResolveType<E> | undefined instead of only undefined. Runtime behavior was already correct; this matches useSuspense() and useCache() and lets callers use fields like data?.title without casts.

The nullable-args overload is updated in React (useDLE.ts / .native.ts) and Vue useDLE. Unused CondNull / SuspenseReturn helpers in packages/react/src/hooks/types.ts are removed (nothing imported them). React and Vue tests cover schema-less endpoints with nullable args and type-check expectations.

Reviewed by Cursor Bugbot for commit 5671c93. Bugbot is set up for automated code reviews on this repo. Configure here.

The nullable-args overload typed data as undefined when the endpoint has
no schema. Use ResolveType<E> | undefined, like useSuspense() and
useCache(). Applies to React (web and native) and Vue.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Y5C5ZEDW88C3UEjiAGULfv
@ntucker ntucker self-assigned this Nov 20, 2026
@changeset-bot

changeset-bot Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 5671c93

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

This PR includes changesets to release 5 packages
Name Type
@data-client/react Patch
@data-client/vue Patch
example-benchmark-react 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

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-20T01:28:10.778540Z 147c308 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

ntucker commented Nov 20, 2026 •

Copy link
Copy Markdown
Collaborator Author

Staff Reviewer: LGTM 5671c93

Validated: read the 147c308..5671c93 delta (one commit, tests only). The React and Vue useDLE tests for schema-less endpoints with nullable args now check the whole data object ({ id: 5, title: 'hi' }) alongside the typed data?.title check. That adds a runtime check and doesn't change any source or types.

Not run locally: typecheck and tests. CI and Bugbot were still pending when I posted this.

@github-actions

Copy link
Copy Markdown
Contributor

Size Change: 0 B

Total Size: 97.5 kB

ℹ️ View Unchanged
Filename Size
examples/test-bundlesize/dist/App.js 1.25 kB
examples/test-bundlesize/dist/polyfill.js 244 B
examples/test-bundlesize/dist/rdcClient.js 9.62 kB
examples/test-bundlesize/dist/rdcEndpoint.js 7.47 kB
examples/test-bundlesize/dist/rdcNextjs.js 11.2 kB
examples/test-bundlesize/dist/rdcPipeableStream.js 8.65 kB
examples/test-bundlesize/dist/react.js 58.5 kB
examples/test-bundlesize/dist/webpack-runtime.js 577 B

compressed-size-action

@github-actions

github-actions Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Docs preview: https://docs-site-pr-4709-data-client.vercel.app

Built from 5671c93 merged into master (this build). Locales: en (the merge queue builds every locale).

@codecov

codecov Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.64%. Comparing base (00b129c) to head (5671c93).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #4709   +/-   ##
=======================================
  Coverage   98.64%   98.64%           
=======================================
  Files         163      163           
  Lines        3164     3164           
  Branches      629      629           
=======================================
  Hits         3121     3121           
  Misses          9        9           
  Partials       34       34           

☔ View full report in Codecov by Harness.
📢 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.

@github-actions github-actions Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Benchmark React

Details
Benchmark suite Current: 5671c93 Previous: 5e42275 Ratio
data-client: getlist-100 374.53 ops/s (± 1.8%) 270.97 ops/s (± 4.3%) 0.72
data-client: getlist-500 101.06 ops/s (± 3.0%) 73.07 ops/s (± 3.6%) 0.72
data-client: update-entity 1111.11 ops/s (± 3.3%) 660.07 ops/s (± 1.9%) 0.59
data-client: update-user 970.87 ops/s (± 3.8%) 583.09 ops/s (± 2.4%) 0.60
data-client: getlist-500-sorted 94.91 ops/s (± 2.4%) 66.86 ops/s (± 3.1%) 0.70
data-client: update-entity-sorted 695.67 ops/s (± 3.1%) 505.05 ops/s (± 2.9%) 0.73
data-client: update-entity-multi-view 814.67 ops/s (± 3.5%) 490.2 ops/s (± 2.3%) 0.60
data-client: list-detail-switch-10 29.48 ops/s (± 5.5%) 8.82 ops/s (± 5.6%) 0.30
data-client: update-user-10000 166.49 ops/s (± 2.8%) 128.53 ops/s (± 1.2%) 0.77
data-client: invalidate-and-resolve 132.93 ops/s (± 2.3%) 84.85 ops/s (± 2.6%) 0.64
data-client: update-ticker-stream 16.04 ops/s (± 1.2%) 10.72 ops/s (± 1.3%) 0.67
data-client: unshift-item 608.83 ops/s (± 2.9%) 331.68 ops/s (± 2.4%) 0.54
data-client: delete-item 813.02 ops/s (± 2.8%) 547.2 ops/s (± 3.5%) 0.67
data-client: move-item 469.48 ops/s (± 2.7%) 320.51 ops/s (± 2.0%) 0.68

This comment was automatically generated by workflow using github-action-benchmark.

…uspenseReturn type

SuspenseReturn and CondNull in react hooks/types.ts were unused and still
carried the old undefined typing for schema-less nullable args.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Y5C5ZBtGvJe2W3ajt3TdxV
…LE tests

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Y5C5ZBtGvJe2W3ajt3TdxV
@ntucker
ntucker added this pull request to the merge queue Nov 20, 2026
Merged via the queue into master with commit a218d22 Nov 20, 2026
41 checks passed
@ntucker
ntucker deleted the claude/project-thread-y69pdb branch November 20, 2026 01:46
@github-actions github-actions Bot mentioned this pull request Nov 20, 2026
ntucker added a commit to ntucker/chess that referenced this pull request Nov 29, 2026
0.19.1 types useDLE()'s data for schema-less endpoints with nullable
args (reactive/data-client#4709). Chess no longer has a workaround for
it to remove.


Claude-Session: https://claude.ai/code/session_01Y5C5ZB9HnFSLPt4AWFXpZW

Co-authored-by: Claude <noreply@anthropic.com>
ntucker pushed a commit that referenced this pull request Nov 29, 2026
…lable)

The "no schema -> ResolveType<E>" rule was hand-written in ~32 places and
drifted twice (#4709, #4718). Export EndpointData, EndpointDataNullable and
ResultEntry from normalizr (mirrored in endpoint) and use them in core,
react and vue. An ESLint rule forbids new hand-written E['schema']
conditionals in core/react/vue; the few kept for annotation compatibility
are listed in plans/next-breaking-release.md. Type-test matrices pin every
read API to the shared types.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Y5C5ZB1tnwGuQL4pYksPv1
ntucker added a commit that referenced this pull request Nov 29, 2026
…ss data (#4718)

* fix: getResponse() types data for schema-less endpoints

Controller and Snapshot getResponse()/getResponseMeta() typed data as
undefined when the endpoint has no schema. Use ResolveType<E> | undefined,
like useCache() and useDLE().

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Y5C5ZB1tnwGuQL4pYksPv1

* internal: Format getResponse changeset example

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Y5C5ZB1tnwGuQL4pYksPv1

* fix: Snapshot types in endpoint and normalizr match getResponse() data

SnapshotInterface (what update functions receive) still typed schema-less
data as undefined. Explain the non-callable fallback and the union args in
the test.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Y5C5ZB1tnwGuQL4pYksPv1

* internal: Check both SnapshotInterface reads in getResponse test

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Y5C5ZB1tnwGuQL4pYksPv1

* fix: One owner for endpoint data types (EndpointData, EndpointDataNullable)

The "no schema -> ResolveType<E>" rule was hand-written in ~32 places and
drifted twice (#4709, #4718). Export EndpointData, EndpointDataNullable and
ResultEntry from normalizr (mirrored in endpoint) and use them in core,
react and vue. An ESLint rule forbids new hand-written E['schema']
conditionals in core/react/vue; the few kept for annotation compatibility
are listed in plans/next-breaking-release.md. Type-test matrices pin every
read API to the shared types.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Y5C5ZB1tnwGuQL4pYksPv1

* internal: Pin fetch and useFetch endpoint data types, clearer lint message

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Y5C5ZB1tnwGuQL4pYksPv1

* internal: Simplify endpoint data type tests and useFetch lint exemption

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Y5C5ZB1tnwGuQL4pYksPv1

* internal: Clean up endpoint data lint comments and test notes

Move the overload rule's reason next to its selector, correct the
mirror-parity test note (only EndpointDataNullable differs for entity
schemas), and drop unused NI imports in edited hooks.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Y5C5ZB1tnwGuQL4pYksPv1

* internal: Simplify endpoint data type tests; note why fetch keeps SchemaResult

Pass maybe-null args directly in the react type test, drop the vue test's
alias-against-itself asserts (react's owner block covers them), and note
that SchemaResult also covers plain functions with no schema member,
which EndpointData does not.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Y5C5ZB1tnwGuQL4pYksPv1

* internal: Drop endpoint data lint rule; the shared types are enough

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Y5C5ZB1tnwGuQL4pYksPv1

* docs: Show the getResponse() fix with an optimistic update example

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Y5C5ZB1tnwGuQL4pYksPv1

---------

Co-authored-by: Claude <noreply@anthropic.com>

This branch was successfully deployed

1 active deployment
docs-preview — 5671c93a Deployed Nov 20, 2026 by ntucker via preview / docs deploy #6297
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