diff --git a/types/react-native/index.d.ts b/types/react-native/index.d.ts index f66e46cb1e..ad8abe57fd 100644 --- a/types/react-native/index.d.ts +++ b/types/react-native/index.d.ts @@ -8465,8 +8465,8 @@ export namespace Animated { export function parallel(animations: Array, config?: ParallelConfig): CompositeAnimation; type Mapping = { [key: string]: Mapping } | AnimatedValue; - interface EventConfig { - listener?: ValueListenerCallback; + interface EventConfig { + listener?: (event?: NativeSyntheticEvent) => void; useNativeDriver?: boolean; } @@ -8486,7 +8486,7 @@ export namespace Animated { * ]), *``` */ - export function event(argMapping: Array, config?: EventConfig): (...args: any[]) => void; + export function event(argMapping: Array, config?: EventConfig): (...args: any[]) => void; /** * Make any React component Animatable. Used to create `Animated.View`, etc. diff --git a/types/react-native/test/animated.tsx b/types/react-native/test/animated.tsx index c27af04bb9..40f8c37ee7 100644 --- a/types/react-native/test/animated.tsx +++ b/types/react-native/test/animated.tsx @@ -1,6 +1,6 @@ -import * as React from "react-native"; +import * as React from "react"; -import { Animated, View } from "react-native"; +import { Animated, View, NativeSyntheticEvent, NativeScrollEvent } from "react-native"; function TestAnimatedAPI() { // Value @@ -63,6 +63,17 @@ function TestAnimatedAPI() { Animated.stagger(100, [spring1, springXY]); + const listener = (e?: NativeSyntheticEvent) => { + if (e) { + console.warn(e.nativeEvent.contentOffset.y); + } + }; + + Animated.event( + [{ nativeEvent: { contentOffset: { y: v1 } } }], + { useNativeDriver: true, listener }, + ); + return (