You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(rest): SoftPathArgs for widened path inference in RestEndpoint subclasses (#3847)
* fix(rest): Guard RestEndpoint/ConstructorOptions against O=any inference
Add `unknown extends O ? any :` before the searchParams conditional in
RestEndpoint<O> and RestEndpointConstructorOptions<O>. When subclassing
with `O extends RestGenerics = any`, this catches O=any before it reaches
PathArgs, preventing the restrictive index-signature type.
Includes detailed comment explaining the partial inference limitation
where TypeScript may widen path literals to `string` due to complex
conditional constructor parameter types.
Follows up on #3845 which fixed PathArgs<any> but missed the higher-level
propagation through RestEndpointTypes.
Made-with: Cursor
* fix(rest): SoftPathArgs collapses widened path to unknown for subclass constructors
Introduce SoftPathArgs<P> that resolves PathArgs<string> to `unknown`,
preventing union overloads in ParamFetchWithBody when path widens.
Infer method as POST when explicit body is provided.
Add comprehensive type tests for widened-path endpoints (all callback
overrides: getOptimisticResponse, key, url, process) and resource()
with AuthdEndpoint subclass (extend per-endpoint, object form,
function form).
Update src-4.0-types legacy replacement with SoftPathArgs export.
Made-with: Cursor
* fix: Cover more cases
* docs: Changeset from user view
* fix: Method property type lacks body-based inference, causing inconsistency
Fix TypeScript for `RestEndpoint` subclasses when the path is inferred as `string`
6
+
7
+
If you extend `RestEndpoint` with a generic such as `O extends RestGenerics = any`, TypeScript can widen a path literal to `string`. Constructor callbacks like `getOptimisticResponse`, `key`, `url`, and `process` could then get the wrong parameter types (or unusable unions), even though calling the endpoint still worked at runtime.
8
+
9
+
The same problem could show up when you set `searchParams: undefined` explicitly next to a `body` and a widened path. Both cases now type-check as you would expect.
Copy file name to clipboardExpand all lines: .cursor/skills/changeset/SKILL.md
+18-10Lines changed: 18 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
---
2
2
name: changeset
3
-
description: Create changesets for version bump, release notes, changelog, semver patch/minor/major, breaking changes, documentation and skill updates after code changes
3
+
description: Create user-focused changesets (changelog entries) for semver bumps, release notes, breaking changes, and docs; prefer impact and code examples over implementation detail
4
4
disable-model-invocation: true
5
5
---
6
6
@@ -27,6 +27,7 @@ Generate changesets, update documentation, draft blog entries, and update skills
27
27
- Select all affected packages (direct + transitive)
28
28
- Choose appropriate version bump (patch/minor/major)
29
29
- For packages under 1.0, use minor for breaking changes
30
+
- When writing the markdown body, follow **Changeset body quality** below (user-visible outcome, code examples when helpful, no internal implementation narrative)
30
31
31
32
4.**Update documentation**
32
33
- Update primary docs in `docs/` for any changed public APIs
@@ -47,19 +48,26 @@ Generate changesets, update documentation, draft blog entries, and update skills
47
48
- If new APIs or patterns are introduced that agents should know about, add them to the relevant skill
48
49
- Skill changes don't need changesets — they are development tooling, not published packages
49
50
50
-
## Writing Perspective
51
-
All user-facing text (changesets, blog entries, docs) should be written from the library user's point of view. Describe what was broken or what they can now do — not internal type mechanics or implementation details. Think "what does a developer using this package experience?"
51
+
## Writing perspective
52
+
All user-facing text (changesets, blog entries, docs) should be written from the library user's point of view. Answer: **what did the user see go wrong, and what works for them now?** Avoid internal names (conditional types, branch names, helper types like `SoftPathArgs`, file paths, PR numbers) unless the audience is maintainers reading a technical appendix — changeset bodies are for consumers reading the changelog.
52
53
53
-
## Changeset Format
54
+
## Changeset body quality
55
+
1.**Lead with impact** — One short title line, then 1–3 sentences on behavior: errors gone, typings improved, new capability, migration note.
56
+
2.**User vocabulary** — Name public APIs (`RestEndpoint`, `resource()`, hook names). Do not explain how the fix was implemented.
57
+
3.**When to add code** — Prefer a minimal example when the change is TypeScript-only or subtle: show the pattern that was broken and now works (subclass, `extend`, option object). Skip examples for trivial renames or obvious one-line fixes.
58
+
4.**Examples** — Realistic imports and types; omit unrelated options. For fixes, you can show one “now types correctly” snippet instead of a long before/after if the before state was “TypeScript error on …”.
59
+
5.**Breaking changes** — Still say what the user must do; use Before/After sections with code when the migration is non-obvious.
0 commit comments