Skip to content

Animated regular/calculated issue #504

@MoOx

Description

@MoOx

I am currently having an optional interpolation depending on an optional animated value

~transform=[|
  Transform.translateY(
    ~translateY=
      Animated.(
        animatedFloat(
          scrollYAnimatedValue
          ->Option.map(scrollYAnimatedValue =>
              Animated.Value.add(
                state.animation,
                Value.interpolate(
                  scrollYAnimatedValue,
                  Interpolation.(
                    config(
                      ~inputRange=[|(-200.), 1.|],
                      ~outputRange=
                        fromFloatArray([|(-200.), 1.|]),
                      (),
                    )
                  ),
                ),
              )
            )
          ->Option.getWithDefault(state.animation),
        )
      ),
  ),
|],

This code should work but doesn't compile, complaining that ->Option.getWithDefault(state.animation) isn't the same type as the interpolation.

Error: This expression has type
         ReactNative.Animated.value(ReactNative.Animated.regular) =
           ReactNative.Animated.value(ReactNative.Animated.regular)
       but an expression was expected of type
         ReactNative.Animated.value(ReactNative.Animated.calculated) =
           ReactNative.Animated.value(ReactNative.Animated.calculated)
       Type ReactNative.Animated.regular = ReactNative.Animated.regular
       is not compatible with type
         ReactNative.Animated.calculated = ReactNative.Animated.calculated

We should have something to tell that a regular & calculated are the same at the end, don't we?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions