Skip to content

docs: clarify SpringValues typing vs CSSProperties#2508

Merged
joshuaellis merged 1 commit into
nextfrom
docs/clarify-springvalues-typing
May 22, 2026
Merged

docs: clarify SpringValues typing vs CSSProperties#2508
joshuaellis merged 1 commit into
nextfrom
docs/clarify-springvalues-typing

Conversation

@joshuaellis
Copy link
Copy Markdown
Member

Why

#1645 reports two TypeScript errors that both still reproduce on next but are working-as-designed:

  • SpringValues<T> is not structurally React.CSSProperties — each entry is a SpringValue instance, not a primitive. Typing a child component's prop as CSSProperties is too narrow.
  • Strict literal unions like CSSProperties['pointerEvents'] deliberately reject SpringValue<string> so typos inside useSpring (pointerEvents: 'fooo') stay caught. The error people hit is TS widening a ternary like showMenu ? 'all' : 'none' to string at the config seam.

Loosening either type would weaken safety for everyone to paper over patterns that have clean call-site fixes. Better to document the patterns.

Changes

  • Expanded the SpringValues glossary entry with subsections for child-component typing and literal-value widening.
  • Added a Typing components that receive animated styles section to the Animated Elements concept page.
  • Added SpringValues to the useTransition TS Glossary list (was missing).

Closes #1645

Document the two patterns users hit when forwarding animated styles or
narrowing literal values inside useSpring, and link them from the
useTransition glossary.

Closes #1645
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 22, 2026

⚠️ No Changeset found

Latest commit: 197c72f

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 Error Error May 22, 2026 8:49am

Request Review

@joshuaellis joshuaellis merged commit f2990d4 into next May 22, 2026
8 of 9 checks passed
@joshuaellis joshuaellis deleted the docs/clarify-springvalues-typing branch May 22, 2026 08:50
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.

Typescript: Assigning useTransition return value to a prop with type CSSProperties results in 'not assignable' error

1 participant