Skip to content

[v9.0.0-rc.3] TypeScript types not compatible with latest @types/react (16.9.44) #1102

@bengry

Description

@bengry

🐛 Bug Report

A new version of @types/react recently came out which depends on [email protected], which in turn has better type definitions for CSS properties.
The latest [email protected] is incompatible with these types when trying to use the style prop on animated components, throwing this example error (I used the opacity property, but the same holds true for most other properties):

  Types of property 'opacity' are incompatible.
    Type 'SpringValue<number>' is not assignable to type '"initial" | "inherit" | "-moz-initial" | "revert" | "unset" | FluidValue<Globals, any> | undefined'.
      Type 'SpringValue<number>' is not assignable to type 'FluidValue<Globals, any>'.
        The types returned by 'get()' are incompatible between these types.
          Type 'number' is not assignable to type 'Globals'.ts(2322)

To Reproduce

Try to use the useTransition hook with it's returned callback, and render an <animated.div /> with the styles given by the callback (see repro link).

Expected behavior

There should not be a compile-time error for the style prop.

Link to repro (highly encouraged)

https://codesandbox.io/s/elegant-mclaren-39xuy?file=/src/App.tsx

Environment

  • react-spring v9.0.0-rc.3
  • react v16.13.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions