diff --git a/types/react-native/index.d.ts b/types/react-native/index.d.ts index e655d2b922..018f009fcc 100644 --- a/types/react-native/index.d.ts +++ b/types/react-native/index.d.ts @@ -3994,7 +3994,7 @@ export interface FlatListProps extends VirtualizedListProps { removeClippedSubviews?: boolean; } -export class FlatList extends React.Component> { +export class FlatList extends React.Component> { /** * Scrolls to the end of the content. May be janky without `getItemLayout` prop. */ @@ -4227,7 +4227,7 @@ export interface SectionListScrollParams { viewPosition?: number; } -export class SectionList extends React.Component> { +export class SectionList extends React.Component> { /** * Scrolls to the item at the specified sectionIndex and itemIndex (within the section) * positioned in the viewable area such that viewPosition 0 places it at the top @@ -8472,21 +8472,38 @@ export namespace Animated { */ export function event(argMapping: Array, config?: EventConfig): (...args: any[]) => void; + export type ComponentProps = T extends React.ComponentType | React.Component ? P : never; + + export interface WithAnimatedValue + extends ThisType< + T extends object + ? { [K in keyof T]?: WithAnimatedValue } + : T extends (infer P)[] + ? WithAnimatedValue

[] + : T | Value | AnimatedInterpolation + > {} + + export type AnimatedProps = { [key in keyof T]: WithAnimatedValue }; + + export interface AnimatedComponent> | React.Component>> extends React.FC>> { + getNode: () => T; + } + /** * Make any React component Animatable. Used to create `Animated.View`, etc. */ - export function createAnimatedComponent(component: any): any; + export function createAnimatedComponent> | React.Component>>(component: T): AnimatedComponent> ? InstanceType : T>; /** * Animated variants of the basic native views. Accepts Animated.Value for * props and style. */ - export const View: any; - export const Image: any; - export const Text: any; - export const ScrollView: any; - export const FlatList: any; - export const SectionList: any; + export const View: AnimatedComponent; + export const Image: AnimatedComponent; + export const Text: AnimatedComponent; + export const ScrollView: AnimatedComponent; + export const FlatList: AnimatedComponent; + export const SectionList: AnimatedComponent; } // tslint:disable-next-line:interface-name diff --git a/types/react-native/test/animated.tsx b/types/react-native/test/animated.tsx index a742040caf..6a7450f7c3 100644 --- a/types/react-native/test/animated.tsx +++ b/types/react-native/test/animated.tsx @@ -84,7 +84,7 @@ function TestAnimatedAPI() { ]} /> - + ); }