Skip to content

test(types): restore TypeScript 5.9 to CI matrix#2464

Merged
joshuaellis merged 1 commit into
nextfrom
test/2441
May 22, 2026
Merged

test(types): restore TypeScript 5.9 to CI matrix#2464
joshuaellis merged 1 commit into
nextfrom
test/2441

Conversation

@joshuaellis
Copy link
Copy Markdown
Member

Summary

TypeScript 5.9 tightened conditional-return-type assignability, which broke five generic helpers in the core/shared packages. Each return type was correct in intent but unprovable to the compiler because TS does not propagate value-side narrowing through user-defined type guards back into a generic conditional return type. Patched each site with the most honest option available and restored 5.9 to the test-types matrix.

Approach

Per site, picked the cleanest fix:

  • callProp — replaced the single conditional-return signature with function overloads so no cast is needed in the body.
  • computeGoal — rewrote as guarded returns, each branch cast to the declared return type T.
  • getDefaultProp — widened the return type to T[P] | undefined to match actual behaviour. Existing callers (SpringValue, Controller, hasDefaultProp) already handle undefined via is.und, === true, or !==.
  • toArray — replaced as any with as Arrify<Exclude<T, void>> on the result.

as any was deliberately avoided — as <ReturnType> keeps the structural compatibility check the compiler can still perform.

Verification

tsc --noEmit clean on TS 5.0, 5.4, 5.7, 5.9. Unit suite passes (217 tests).

Closes #2441

TS 5.9 tightened conditional-return-type assignability, which surfaced
five errors in two helper modules where generic returns relied on flow
narrowing through user-defined type guards. TypeScript does not
propagate value-side narrowing back into a generic conditional return
type, so each site needed either overloads or a typed cast.

- callProp: replaced the conditional return with function overloads so
  no cast is required in the body.
- computeGoal: rewrote as guarded returns, each branch cast to T.
- getDefaultProp: return type widened to T[P] | undefined to match
  actual behaviour; existing callers already handled undefined.
- toArray: replaced as-any with as-Arrify on the result.

Restored 5.9 to the test-types matrix. Verified clean on tsc --noEmit
against 5.0, 5.4, 5.7, 5.9.

Closes #2441
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 22, 2026

⚠️ No Changeset found

Latest commit: e987da7

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@vercel
Copy link
Copy Markdown

vercel Bot commented May 22, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
react-spring Ready Ready Preview May 22, 2026 5:56am

Request Review

@joshuaellis joshuaellis merged commit 6338cef into next May 22, 2026
17 checks passed
@joshuaellis joshuaellis deleted the test/2441 branch May 22, 2026 05:58
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.

test(types): restore TypeScript 5.9 to CI matrix

1 participant