diff --git a/Libraries/Animated/Animated.d.ts b/Libraries/Animated/Animated.d.ts index 3301ff377246ff..fb2aeafc5eaca7 100644 --- a/Libraries/Animated/Animated.d.ts +++ b/Libraries/Animated/Animated.d.ts @@ -11,8 +11,12 @@ import type * as React from 'react'; import {ScrollView} from '../Components/ScrollView/ScrollView'; import {View} from '../Components/View/View'; import {Image} from '../Image/Image'; -import {FlatListProps} from '../Lists/FlatList'; -import {DefaultSectionT, SectionListProps} from '../Lists/SectionList'; +import {FlatListComponent, FlatListProps} from '../Lists/FlatList'; +import { + DefaultSectionT, + SectionListComponent, + SectionListProps, +} from '../Lists/SectionList'; import {ColorValue} from '../StyleSheet/StyleSheet'; import {Text} from '../Text/Text'; import {NativeSyntheticEvent} from '../Types/CoreEventTypes'; @@ -598,13 +602,18 @@ export namespace Animated { /** * FlatList and SectionList infer generic Type defined under their `data` and `section` props. */ - export class FlatList extends React.Component< + + export class FlatList extends FlatListComponent< + ItemT, AnimatedProps> > {} + export class SectionList< ItemT = any, SectionT = DefaultSectionT, - > extends React.Component>> {} + > extends SectionListComponent< + AnimatedProps> + > {} } // We need to alias these views so we can reference them in the Animated diff --git a/Libraries/Lists/FlatList.d.ts b/Libraries/Lists/FlatList.d.ts index 8676fb4d28b4f8..d3e350c01971a7 100644 --- a/Libraries/Lists/FlatList.d.ts +++ b/Libraries/Lists/FlatList.d.ts @@ -166,9 +166,10 @@ export interface FlatListProps extends VirtualizedListProps { fadingEdgeLength?: number | undefined; } -export class FlatList extends React.Component< - FlatListProps -> { +export abstract class FlatListComponent< + ItemT, + Props, +> extends React.Component { /** * Scrolls to the end of the content. May be janky without `getItemLayout` prop. */ @@ -236,3 +237,8 @@ export class FlatList extends React.Component< // TODO: use `unknown` instead of `any` for Typescript >= 3.0 setNativeProps: (props: {[key: string]: any}) => void; } + +export class FlatList extends FlatListComponent< + ItemT, + FlatListProps +> {} diff --git a/Libraries/Lists/SectionList.d.ts b/Libraries/Lists/SectionList.d.ts index 7ff5bbb0a3cbe1..0e2313702d6cca 100644 --- a/Libraries/Lists/SectionList.d.ts +++ b/Libraries/Lists/SectionList.d.ts @@ -210,10 +210,9 @@ export interface SectionListScrollParams { viewPosition?: number | undefined; } -export class SectionList< - ItemT = any, - SectionT = DefaultSectionT, -> extends React.Component> { +export abstract class SectionListComponent< + Props, +> 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 @@ -246,6 +245,11 @@ export class SectionList< getScrollableNode(): NodeHandle | undefined; } +export class SectionList< + ItemT = any, + SectionT = DefaultSectionT, +> extends SectionListComponent> {} + /* This definition is deprecated because it extends the wrong base type */ export interface SectionListStatic extends React.ComponentClass> {