Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions types/react-native/Libraries/Lists/FlatList.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export interface FlatListProps<ItemT> extends VirtualizedListProps<ItemT> {
*/
ListEmptyComponent?:
| React.ComponentType<any>
| React.ReactElement
| React.ReactElement<unknown>
| null
| undefined;

Expand All @@ -29,7 +29,7 @@ export interface FlatListProps<ItemT> extends VirtualizedListProps<ItemT> {
*/
ListFooterComponent?:
| React.ComponentType<any>
| React.ReactElement
| React.ReactElement<unknown>
| null
| undefined;

Expand All @@ -43,7 +43,7 @@ export interface FlatListProps<ItemT> extends VirtualizedListProps<ItemT> {
*/
ListHeaderComponent?:
| React.ComponentType<any>
| React.ReactElement
| React.ReactElement<unknown>
| null
| undefined;

Expand Down
8 changes: 4 additions & 4 deletions types/react-native/Libraries/Lists/SectionList.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export interface SectionListProps<ItemT, SectionT = DefaultSectionT>
*/
ListEmptyComponent?:
| React.ComponentType<any>
| React.ReactElement
| React.ReactElement<unknown>
| null
| undefined;

Expand All @@ -71,7 +71,7 @@ export interface SectionListProps<ItemT, SectionT = DefaultSectionT>
*/
ListFooterComponent?:
| React.ComponentType<any>
| React.ReactElement
| React.ReactElement<unknown>
| null
| undefined;

Expand All @@ -85,7 +85,7 @@ export interface SectionListProps<ItemT, SectionT = DefaultSectionT>
*/
ListHeaderComponent?:
| React.ComponentType<any>
| React.ReactElement
| React.ReactElement<unknown>
| null
| undefined;

Expand All @@ -99,7 +99,7 @@ export interface SectionListProps<ItemT, SectionT = DefaultSectionT>
*/
SectionSeparatorComponent?:
| React.ComponentType<any>
| React.ReactElement
| React.ReactElement<unknown>
| null
| undefined;

Expand Down
6 changes: 3 additions & 3 deletions types/react-native/Libraries/Lists/VirtualizedList.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export interface VirtualizedListWithoutRenderItemProps<ItemT>
*/
ListEmptyComponent?:
| React.ComponentType<any>
| React.ReactElement
| React.ReactElement<unknown>
| null
| undefined;

Expand All @@ -138,7 +138,7 @@ export interface VirtualizedListWithoutRenderItemProps<ItemT>
*/
ListFooterComponent?:
| React.ComponentType<any>
| React.ReactElement
| React.ReactElement<unknown>
| null
| undefined;

Expand All @@ -153,7 +153,7 @@ export interface VirtualizedListWithoutRenderItemProps<ItemT>
*/
ListHeaderComponent?:
| React.ComponentType<any>
| React.ReactElement
| React.ReactElement<unknown>
| null
| undefined;

Expand Down
5 changes: 5 additions & 0 deletions types/react-native/test/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -652,6 +652,11 @@ export class FlatListTest extends React.Component<FlatListProps<number>, {}> {
);

render() {
const { ListEmptyComponent } = this.props;
const listEmptyComponent: JSX.Element | null | undefined = React.isValidElement(ListEmptyComponent)
? ListEmptyComponent
: ListEmptyComponent && <ListEmptyComponent />;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ListEmptyComponent is not narrowed to ReactElement<unknown> if a union member is ReactElement<any>. But with the change in this PR the full type is ReactElement<unknown> | ... so isValidElement does narrow it again.


return (
<FlatList
ref={list => (this.list = list)}
Expand Down
20 changes: 10 additions & 10 deletions types/react-native/v0.63/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3975,12 +3975,12 @@ export interface FlatListProps<ItemT> extends VirtualizedListProps<ItemT> {
/**
* Rendered when the list is empty.
*/
ListEmptyComponent?: React.ComponentType<any> | React.ReactElement | null;
ListEmptyComponent?: React.ComponentType<any> | React.ReactElement<unknown> | null;

/**
* Rendered at the very end of the list.
*/
ListFooterComponent?: React.ComponentType<any> | React.ReactElement | null;
ListFooterComponent?: React.ComponentType<any> | React.ReactElement<unknown> | null;

/**
* Styling for internal View for ListFooterComponent
Expand All @@ -3990,7 +3990,7 @@ export interface FlatListProps<ItemT> extends VirtualizedListProps<ItemT> {
/**
* Rendered at the very beginning of the list.
*/
ListHeaderComponent?: React.ComponentType<any> | React.ReactElement | null;
ListHeaderComponent?: React.ComponentType<any> | React.ReactElement<unknown> | null;

/**
* Styling for internal View for ListHeaderComponent
Expand Down Expand Up @@ -4245,22 +4245,22 @@ export interface SectionListProps<ItemT, SectionT = DefaultSectionT>
/**
* Rendered when the list is empty.
*/
ListEmptyComponent?: React.ComponentType<any> | React.ReactElement | null;
ListEmptyComponent?: React.ComponentType<any> | React.ReactElement<unknown> | null;

/**
* Rendered at the very end of the list.
*/
ListFooterComponent?: React.ComponentType<any> | React.ReactElement | null;
ListFooterComponent?: React.ComponentType<any> | React.ReactElement<unknown> | null;

/**
* Rendered at the very beginning of the list.
*/
ListHeaderComponent?: React.ComponentType<any> | React.ReactElement | null;
ListHeaderComponent?: React.ComponentType<any> | React.ReactElement<unknown> | null;

/**
* Rendered in between each section.
*/
SectionSeparatorComponent?: React.ComponentType<any> | React.ReactElement | null;
SectionSeparatorComponent?: React.ComponentType<any> | React.ReactElement<unknown> | null;

/**
* A marker property for telling the list to re-render (since it implements PureComponent).
Expand Down Expand Up @@ -4467,19 +4467,19 @@ export interface VirtualizedListWithoutRenderItemProps<ItemT> extends ScrollView
* Rendered when the list is empty. Can be a React Component Class, a render function, or
* a rendered element.
*/
ListEmptyComponent?: React.ComponentType<any> | React.ReactElement | null;
ListEmptyComponent?: React.ComponentType<any> | React.ReactElement<unknown> | null;

/**
* Rendered at the bottom of all the items. Can be a React Component Class, a render function, or
* a rendered element.
*/
ListFooterComponent?: React.ComponentType<any> | React.ReactElement | null;
ListFooterComponent?: React.ComponentType<any> | React.ReactElement<unknown> | null;

/**
* Rendered at the top of all the items. Can be a React Component Class, a render function, or
* a rendered element.
*/
ListHeaderComponent?: React.ComponentType<any> | React.ReactElement | null;
ListHeaderComponent?: React.ComponentType<any> | React.ReactElement<unknown> | null;

/**
* The default accessor functions assume this is an Array<{key: string}> but you can override
Expand Down
20 changes: 10 additions & 10 deletions types/react-native/v0.64/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3992,12 +3992,12 @@ export interface FlatListProps<ItemT> extends VirtualizedListProps<ItemT> {
/**
* Rendered when the list is empty.
*/
ListEmptyComponent?: React.ComponentType<any> | React.ReactElement | null | undefined;
ListEmptyComponent?: React.ComponentType<any> | React.ReactElement<unknown> | null | undefined;

/**
* Rendered at the very end of the list.
*/
ListFooterComponent?: React.ComponentType<any> | React.ReactElement | null | undefined;
ListFooterComponent?: React.ComponentType<any> | React.ReactElement<unknown> | null | undefined;

/**
* Styling for internal View for ListFooterComponent
Expand All @@ -4007,7 +4007,7 @@ export interface FlatListProps<ItemT> extends VirtualizedListProps<ItemT> {
/**
* Rendered at the very beginning of the list.
*/
ListHeaderComponent?: React.ComponentType<any> | React.ReactElement | null | undefined;
ListHeaderComponent?: React.ComponentType<any> | React.ReactElement<unknown> | null | undefined;

/**
* Styling for internal View for ListHeaderComponent
Expand Down Expand Up @@ -4262,22 +4262,22 @@ export interface SectionListProps<ItemT, SectionT = DefaultSectionT>
/**
* Rendered when the list is empty.
*/
ListEmptyComponent?: React.ComponentType<any> | React.ReactElement | null | undefined;
ListEmptyComponent?: React.ComponentType<any> | React.ReactElement<unknown> | null | undefined;

/**
* Rendered at the very end of the list.
*/
ListFooterComponent?: React.ComponentType<any> | React.ReactElement | null | undefined;
ListFooterComponent?: React.ComponentType<any> | React.ReactElement<unknown> | null | undefined;

/**
* Rendered at the very beginning of the list.
*/
ListHeaderComponent?: React.ComponentType<any> | React.ReactElement | null | undefined;
ListHeaderComponent?: React.ComponentType<any> | React.ReactElement<unknown> | null | undefined;

/**
* Rendered in between each section.
*/
SectionSeparatorComponent?: React.ComponentType<any> | React.ReactElement | null | undefined;
SectionSeparatorComponent?: React.ComponentType<any> | React.ReactElement<unknown> | null | undefined;

/**
* A marker property for telling the list to re-render (since it implements PureComponent).
Expand Down Expand Up @@ -4484,19 +4484,19 @@ export interface VirtualizedListWithoutRenderItemProps<ItemT> extends ScrollView
* Rendered when the list is empty. Can be a React Component Class, a render function, or
* a rendered element.
*/
ListEmptyComponent?: React.ComponentType<any> | React.ReactElement | null | undefined;
ListEmptyComponent?: React.ComponentType<any> | React.ReactElement<unknown> | null | undefined;

/**
* Rendered at the bottom of all the items. Can be a React Component Class, a render function, or
* a rendered element.
*/
ListFooterComponent?: React.ComponentType<any> | React.ReactElement | null | undefined;
ListFooterComponent?: React.ComponentType<any> | React.ReactElement<unknown> | null | undefined;

/**
* Rendered at the top of all the items. Can be a React Component Class, a render function, or
* a rendered element.
*/
ListHeaderComponent?: React.ComponentType<any> | React.ReactElement | null | undefined;
ListHeaderComponent?: React.ComponentType<any> | React.ReactElement<unknown> | null | undefined;

/**
* The default accessor functions assume this is an Array<{key: string}> but you can override
Expand Down
20 changes: 10 additions & 10 deletions types/react-native/v0.65/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4015,12 +4015,12 @@ export interface FlatListProps<ItemT> extends VirtualizedListProps<ItemT> {
/**
* Rendered when the list is empty.
*/
ListEmptyComponent?: React.ComponentType<any> | React.ReactElement | null | undefined;
ListEmptyComponent?: React.ComponentType<any> | React.ReactElement<unknown> | null | undefined;

/**
* Rendered at the very end of the list.
*/
ListFooterComponent?: React.ComponentType<any> | React.ReactElement | null | undefined;
ListFooterComponent?: React.ComponentType<any> | React.ReactElement<unknown> | null | undefined;

/**
* Styling for internal View for ListFooterComponent
Expand All @@ -4030,7 +4030,7 @@ export interface FlatListProps<ItemT> extends VirtualizedListProps<ItemT> {
/**
* Rendered at the very beginning of the list.
*/
ListHeaderComponent?: React.ComponentType<any> | React.ReactElement | null | undefined;
ListHeaderComponent?: React.ComponentType<any> | React.ReactElement<unknown> | null | undefined;

/**
* Styling for internal View for ListHeaderComponent
Expand Down Expand Up @@ -4285,22 +4285,22 @@ export interface SectionListProps<ItemT, SectionT = DefaultSectionT>
/**
* Rendered when the list is empty.
*/
ListEmptyComponent?: React.ComponentType<any> | React.ReactElement | null | undefined;
ListEmptyComponent?: React.ComponentType<any> | React.ReactElement<unknown> | null | undefined;

/**
* Rendered at the very end of the list.
*/
ListFooterComponent?: React.ComponentType<any> | React.ReactElement | null | undefined;
ListFooterComponent?: React.ComponentType<any> | React.ReactElement<unknown> | null | undefined;

/**
* Rendered at the very beginning of the list.
*/
ListHeaderComponent?: React.ComponentType<any> | React.ReactElement | null | undefined;
ListHeaderComponent?: React.ComponentType<any> | React.ReactElement<unknown> | null | undefined;

/**
* Rendered in between each section.
*/
SectionSeparatorComponent?: React.ComponentType<any> | React.ReactElement | null | undefined;
SectionSeparatorComponent?: React.ComponentType<any> | React.ReactElement<unknown> | null | undefined;

/**
* A marker property for telling the list to re-render (since it implements PureComponent).
Expand Down Expand Up @@ -4507,19 +4507,19 @@ export interface VirtualizedListWithoutRenderItemProps<ItemT> extends ScrollView
* Rendered when the list is empty. Can be a React Component Class, a render function, or
* a rendered element.
*/
ListEmptyComponent?: React.ComponentType<any> | React.ReactElement | null | undefined;
ListEmptyComponent?: React.ComponentType<any> | React.ReactElement<unknown> | null | undefined;

/**
* Rendered at the bottom of all the items. Can be a React Component Class, a render function, or
* a rendered element.
*/
ListFooterComponent?: React.ComponentType<any> | React.ReactElement | null | undefined;
ListFooterComponent?: React.ComponentType<any> | React.ReactElement<unknown> | null | undefined;

/**
* Rendered at the top of all the items. Can be a React Component Class, a render function, or
* a rendered element.
*/
ListHeaderComponent?: React.ComponentType<any> | React.ReactElement | null | undefined;
ListHeaderComponent?: React.ComponentType<any> | React.ReactElement<unknown> | null | undefined;

/**
* The default accessor functions assume this is an Array<{key: string}> but you can override
Expand Down
Loading