"Type instantiation is excessively deep and possibly infinite" Typescript error when used with styled-components css prop
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 29.1k
- Forks
- 1.2k
- PR merge metrics
- No merged PRs in 30d
Description
🐛 Bug Report
Using react-spring in conjunction with styled-components css prop in Typescript causes a "Type instantiation is excessively deep and possibly infinite" compilation error.

There are several ways to enable typescript support for the css prop from styled-components in typescript listed here: https://github.com/DefinitelyTyped/DefinitelyTyped/issues/31245 all of which cause this error.
To Reproduce
Steps to reproduce the behavior:
- Create a typescript react app with
npx create-react-app react-spring-css-prop-error --template typescript - Add react-spring, styled-components and types:
yarn add react-spring styled-components @types/styled-components - Add reference to css prop types in App.tsx:
/// <reference types="styled-components/cssprop" /> - Attempt to use animated compenent (e.g. animated.div) in App component
Expected behavior
<animated.div></animated.div> should have no compilation errors
Link to repro
Environment
react-springv9.1.2reactv17.0.2styled-componentsv5.3.0- '@types/styled-components` v5.1.9
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the reproduction from the issue in the linked CodeSandbox or a TypeScript React app, focusing on App.tsx and the animated.div usage. Compare the behavior with react-spring v9.1.2, styled-components v5.3.0, and their listed type packages; done means the animated component compiles without the deep-instantiation error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react, typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100