Skip to content

Commit

Permalink
add event mapping type (#388)
Browse files Browse the repository at this point in the history
  • Loading branch information
ShaMan123 authored and kmagiera committed Sep 21, 2019
1 parent c3c0d71 commit 52ffd70
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions react-native-reanimated.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<Mapping>,
config?: {},
type EventArgFunc<T> = (arg: T) => Node<number>;
type EventMapping<T> = T extends object ? { [K in keyof T]?: EventMapping<T[K]> | EventArgFunc<T[K]> } : Adaptable<T> | EventArgFunc<T>;
type EventMappingArray<T> = T extends Array<any> ? { [I in keyof T]: EventMapping<T[I]> } : [EventMapping<T>]
export function event<T>(
argMapping: T extends never ? ReadonlyArray<Mapping> : Readonly<EventMappingArray<T>>,
config?: {},
): (...args: any[]) => void;

// derived operations
Expand Down

0 comments on commit 52ffd70

Please sign in to comment.