Conversation
resource().extend({ get: ... }) returned CustomResource, which only typed the
five standard endpoints, so members added earlier with extend('key', options)
(and the deprecated create) disappeared from the type while still present at
runtime.
Also add regression tests that extend() option types are checked
(dataExpiryLength etc.) across endpoint and resource extend forms.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0117wFk9RgsnzgqUgJHDepyY
🦋 Changeset detectedLatest commit: e1f1930 The changes in this PR will be included in the next version bump. This PR includes changesets to release 4 packages
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 |
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0117wFk9RgsnzgqUgJHDepyY
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0117wFk9RgsnzgqUgJHDepyY
Contributor
|
Size Change: 0 B Total Size: 103 kB ℹ️ View Unchanged
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #4184 +/- ##
==========================================
+ Coverage 98.06% 98.08% +0.02%
==========================================
Files 163 165 +2
Lines 3098 3139 +41
Branches 617 625 +8
==========================================
+ Hits 3038 3079 +41
Misses 18 18
Partials 42 42 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
ntucker
marked this pull request as ready for review
October 5, 2026 09:24
This branch was successfully deployed
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Requested by Nathaniel · project thread
Motivation
Customizing a resource's standard endpoints with
.extend({ ... })kept every endpoint at runtime, but TypeScript lost the ones added before it with.extend('name', options), and the deprecatedcreate.Solution
The object form of
Extendable.extend()now returnsCustomResource<...> & Omit<R, keyof ResourceInterface | 'extend'>(also in the TS 4.0/4.1 legacy declaration).Omitis used inline rather than a new helper alias so declaration emit in user code (declaration: true) can still name the type.New
typescript-tests/extendOptions.test.tscovers this, plus regression tests thatextend()options are type-checked (dataExpiryLength: 'long'etc.) acrossRestEndpoint.extend(),resource().extend('key', ...)andresource().extend({ get }).Verification:
@ts-expect-errorneutralized is identical before/after on TS 6, except the fixedProperty 'current' does not exist..extend('current').extend({ get })scenario 153,915 → 156,556 (+1.7%, previously 40 errors);resourcesunchanged at 134,294;typical12,995 → 13,398.Open questions
From the original brief, two other gaps were checked:
ep.extend({ dataExpiryLength: 'long' })already fails on master on every TS version from 4.0 to 7 (the message reads "not assignable to type 'never'"). This PR only adds regression tests for it.getOptimisticResponsereturninganyis not fixed here. The right return type is the raw input the schema normalizes, which is what typedController.set()computes incore/src/controller/setManyTypes.ts. That file is being reworked for the set() updater perf regression, so sharing it is queued as a follow-up.🤖 Generated with Claude Code
https://claude.ai/code/session_0117wFk9RgsnzgqUgJHDepyY
Generated by Claude Code
Note
Low Risk
Types-only change in
@data-client/restwith no runtime behavior change; slightly richer intersection types (~1.7% more TS instantiations in one stress scenario).Overview
Fixes a TypeScript-only gap when chaining
resource().extend('name', …)withresource().extend({ get: … })(or other standard endpoint overrides): runtime still had every endpoint, but the object-form return type was onlyCustomResource<…>, so names likecurrentand deprecatedcreatedisappeared from the type.The object overload of
extend()now returnsCustomResource<…> & Omit<R, keyof ResourceInterface | 'extend'>inresourceExtendable.tsand the TS 4.1 legacy declarations, so prior custom members stay on the inferred resource type through further chaining.Adds
typescript-tests/extendOptions.test.tsfor member preservation and forextend()option validation regressions, plus a patch changeset and a v0.19 blog bullet.Reviewed by Cursor Bugbot for commit e1f1930. Bugbot is set up for automated code reviews on this repo. Configure here.