From f4769aa56386505a179eb660c991069a586236d8 Mon Sep 17 00:00:00 2001 From: ShaMan123 <34343793+ShaMan123@users.noreply.github.com> Date: Sat, 21 Sep 2019 23:10:28 +0300 Subject: [PATCH] add event mapping type (#388) (cherry picked from commit 52ffd70eff65035992e4c269125924e11cf0c44c) --- react-native-reanimated.d.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/react-native-reanimated.d.ts b/react-native-reanimated.d.ts index df602d0c15f..93cba44e0f2 100644 --- a/react-native-reanimated.d.ts +++ b/react-native-reanimated.d.ts @@ -253,9 +253,12 @@ declare module 'react-native-reanimated' { export function clockRunning(clock: AnimatedClock): AnimatedNode<0 | 1>; // the return type for `event` is a lie, but it's the same lie that // react-native makes within Animated - export function event( - argMapping: ReadonlyArray, - config?: {}, + type EventArgFunc = (arg: T) => Node; + type EventMapping = T extends object ? { [K in keyof T]?: EventMapping | EventArgFunc } : Adaptable | EventArgFunc; + type EventMappingArray = T extends Array ? { [I in keyof T]: EventMapping } : [EventMapping] + export function event( + argMapping: T extends never ? ReadonlyArray : Readonly>, + config?: {}, ): (...args: any[]) => void; // derived operations