Skip to content

"Type instantiation is excessively deep and possibly infinite" Typescript error when used with styled-components css prop #1515

Open
@matt-winfield

Description

@matt-winfield

🐛 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.

image

There are several ways to enable typescript support for the css prop from styled-components in typescript listed here: DefinitelyTyped/DefinitelyTyped#31245 all of which cause this error.

To Reproduce

Steps to reproduce the behavior:

  1. Create a typescript react app with npx create-react-app react-spring-css-prop-error --template typescript
  2. Add react-spring, styled-components and types: yarn add react-spring styled-components @types/styled-components
  3. Add reference to css prop types in App.tsx: /// <reference types="styled-components/cssprop" />
  4. 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

CodeSandbox repro

Environment

  • react-spring v9.1.2
  • react v17.0.2
  • styled-components v5.3.0
  • '@types/styled-components` v5.1.9

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions