Skip to content

fix(core): infer all animated keys when a partial from is provided#2545

Merged
joshuaellis merged 1 commit into
nextfrom
fix/pick-animated-from-keys
Jun 19, 2026
Merged

fix(core): infer all animated keys when a partial from is provided#2545
joshuaellis merged 1 commit into
nextfrom
fix/pick-animated-from-keys

Conversation

@joshuaellis

Copy link
Copy Markdown
Member

Summary

Stands up type-level testing for react-spring and uses it to fix a real inference regression. When a from prop is provided but doesn't list every animated key, useSpring/useSprings/useTransition were dropping the other keys from their inferred state — useSpring({ width: 100, height: 100, from: { width: 0 } }) typed its result as { width }, so styles.height was a compile error even though height animates fine at runtime. PickAnimated now merges from with the to, forward, and transition-phase values instead of replacing them.

Type-level test harness

Adds a types Vitest project (vitest --typecheck) and a test:types script, wired into test and release. Assertions use expectTypeOf; cases that are known but not yet fixable are pinned with @ts-expect-error, which starts failing the moment the underlying issue is resolved, so nothing rots silently.

Regression coverage

Locks the public type surface against the bugs behind #2541. #2006, #1114 and #1483 are already resolved by the v11 rewrite — these tests stop them regressing. #2183 is covered on the type side; its remaining symptom is runtime and is captured on the issue. The per-key event-handler any leak is documented with a self-policing guard pending a separate fix.

Reviving the type tests

The spec.ts type suites under src/types/__tests__ were excluded from tsc, run by no project, and had drifted out of date — which is exactly how the from regression went unnoticed. They're now co-located beside the code they cover, running under both gates, and brought back in line with current behaviour. The tsconfig exclusion that hid them is removed.

@changeset-bot

changeset-bot Bot commented Jun 19, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: efcdbde

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

This PR includes changesets to release 9 packages
Name Type
@react-spring/core Patch
@react-spring/three Patch
@react-spring/web Patch
@react-spring/parallax Patch
@react-spring/animated Patch
@react-spring/mock-raf Patch
@react-spring/rafz Patch
@react-spring/shared Patch
@react-spring/types 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

Stands up a vitest --typecheck type-test harness and uses it to fix a
PickAnimated regression that dropped forward props, `to` keys, and the
other transition phases from the inferred state whenever a partial
`from` was set. Also revives the orphaned spec.ts type suites and locks
the public type surface behind #2541 against regression.
@joshuaellis joshuaellis force-pushed the fix/pick-animated-from-keys branch from 16f53cc to efcdbde Compare June 19, 2026 11:18
@joshuaellis joshuaellis merged commit e09a310 into next Jun 19, 2026
20 checks passed
@joshuaellis joshuaellis deleted the fix/pick-animated-from-keys branch June 19, 2026 11:30
joshuaellis added a commit that referenced this pull request Jun 24, 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