react-spring icon indicating copy to clipboard operation
react-spring copied to clipboard

[bug]: config.ease throws a type error when used in a Controller, but works fine when used in useSpring

Open looeee opened this issue 3 years ago • 1 comments

Which react-spring target are you using?

  • [X] react-spring

What version of react-spring are you using?

9.4.5

What's Wrong?

config.ease throws a type error when used in a Controller, but works fine when used in useSpring

To Reproduce

import { easings, Controller} from 'react-spring';

const animation = new Controller({
	from: { projectionMatrix: [] as number[] },
	to: { projectionMatrix: [] as number[] },
	config: {
		precision: 0.0001,
		duration: 1000,
		ease: easings.easeOutExpo,
	},
});

Gives the following error:

(property) EasingDictionary.easeOutExpo: (t: number) => number
Type '{ precision: number; duration: number; ease: (t: number) => number; }' is not assignable to type 'Partial<AnimationConfig> | ((key: "projectionMatrix") => Partial<AnimationConfig>)'.
  Object literal may only specify known properties, and 'ease' does not exist in type 'Partial<AnimationConfig> | ((key: "projectionMatrix") => Partial<AnimationConfig>)'.ts(2322)
props.d.ts(167, 5): The expected type comes from property 'config' which is declared here on type 'ControllerUpdate<{ projectionMatrix: number[]; }, undefined>'

Other config props that I have tried are working as expected.

spring error

Expected Behaviour

If I use the same config in the useSpring hook it works as expected.

import { easings, useSpring } from 'react-spring';

const Camera = () => {
    const [, animation] = useSpring(() => ({
        from: { projectionMatrix: [] as number[] },
        to: { projectionMatrix: [] as number[] },
        config: {
            precision: 0.0001,
            duration: 1000,
            ease: easings.easeOutExpo,
        },
    }));
}		

Link to repo

NA

looeee avatar Jun 06 '22 03:06 looeee

am i mistaken, or should the property be easing in both cases?

kindoflew avatar Jun 16 '22 14:06 kindoflew

Yep it should be easing not ease

joshuaellis avatar Sep 11 '22 18:09 joshuaellis