Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,12 @@
*/

'use strict';
import type {HostComponent} from '../../../src/private/types/HostComponent';

Check warning on line 12 in packages/react-native/Libraries/Components/ActivityIndicator/ActivityIndicator.js

View workflow job for this annotation

GitHub Actions / test_js (24)

Requires should be sorted alphabetically, with at least one line between imports/requires and code

Check warning on line 12 in packages/react-native/Libraries/Components/ActivityIndicator/ActivityIndicator.js

View workflow job for this annotation

GitHub Actions / test_js (22.13.0)

Requires should be sorted alphabetically, with at least one line between imports/requires and code
import type {HostInstance} from '../../../src/private/types/HostInstance';
import type {ViewProps} from '../View/ViewPropTypes';

export type ActivityIndicatorInstance = HostInstance;

import StyleSheet, {type ColorValue} from '../../StyleSheet/StyleSheet';
import Platform from '../../Utilities/Platform';
import View from '../View/View';
Expand Down
2 changes: 2 additions & 0 deletions packages/react-native/Libraries/Components/Button.js
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,8 @@ const NativeTouchable:

type ButtonRef = React.ElementRef<typeof NativeTouchable>;

export type ButtonInstance = ButtonRef;

const Button: component(
ref?: React.RefSetter<ButtonRef>,
...props: ButtonProps
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,4 +302,6 @@ const styles = StyleSheet.create({
},
});

export type DrawerLayoutAndroidInstance = DrawerLayoutAndroid;

export default DrawerLayoutAndroid as $FlowFixMe;
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,6 @@

import DrawerLayoutAndroidFallback from './DrawerLayoutAndroidFallback';

export type DrawerLayoutAndroidInstance = DrawerLayoutAndroidFallback;

export default DrawerLayoutAndroidFallback;
Original file line number Diff line number Diff line change
Expand Up @@ -136,3 +136,5 @@ export interface DrawerLayoutAndroidMethods {
): void;
setNativeProps(nativeProps: Object): void;
}

export type DrawerLayoutAndroidInstance = DrawerLayoutAndroidMethods;
Original file line number Diff line number Diff line change
Expand Up @@ -298,4 +298,6 @@ class KeyboardAvoidingView extends React.Component<
}
}

export type KeyboardAvoidingViewInstance = KeyboardAvoidingView;

export default KeyboardAvoidingView;
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
* @format
*/

import type {HostInstance} from '../../../src/private/types/HostInstance';

Check warning on line 11 in packages/react-native/Libraries/Components/Pressable/Pressable.js

View workflow job for this annotation

GitHub Actions / test_js (24)

Requires should be sorted alphabetically, with at least one line between imports/requires and code

Check warning on line 11 in packages/react-native/Libraries/Components/Pressable/Pressable.js

View workflow job for this annotation

GitHub Actions / test_js (22.13.0)

Requires should be sorted alphabetically, with at least one line between imports/requires and code
import type {ViewStyleProp} from '../../StyleSheet/StyleSheet';
import type {
GestureResponderEvent,
Expand All @@ -16,6 +17,8 @@
} from '../../Types/CoreEventTypes';
import type {ViewProps} from '../View/ViewPropTypes';

export type PressableInstance = HostInstance;

import {PressabilityDebugView} from '../../Pressability/PressabilityDebug';
import usePressability from '../../Pressability/usePressability';
import {type RectOrSize} from '../../StyleSheet/Rect';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,13 @@
* @format
*/

import type {HostInstance} from '../../../src/private/types/HostInstance';

Check warning on line 11 in packages/react-native/Libraries/Components/ProgressBarAndroid/ProgressBarAndroid.android.js

View workflow job for this annotation

GitHub Actions / test_js (24)

Requires should be sorted alphabetically, with at least one line between imports/requires and code

Check warning on line 11 in packages/react-native/Libraries/Components/ProgressBarAndroid/ProgressBarAndroid.android.js

View workflow job for this annotation

GitHub Actions / test_js (22.13.0)

Requires should be sorted alphabetically, with at least one line between imports/requires and code
import type {ProgressBarAndroidProps} from './ProgressBarAndroidTypes';

import ProgressBarAndroidNativeComponent from './ProgressBarAndroidNativeComponent';

export type ProgressBarAndroidInstance = HostInstance;

const React = require('react');

export type {ProgressBarAndroidProps};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,14 @@

'use strict';

import type {HostInstance} from '../../../src/private/types/HostInstance';
import typeof ProgressBarAndroidNativeComponentType from './ProgressBarAndroidNativeComponent';
import type {ProgressBarAndroidProps} from './ProgressBarAndroidTypes';

import Platform from '../../Utilities/Platform';

export type ProgressBarAndroidInstance = HostInstance;

export type {ProgressBarAndroidProps};

// A utility type to preserve the semantics of the union uses in the definition
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,4 +205,6 @@ class RefreshControl extends React.Component<RefreshControlProps> {
};
}

export type RefreshControlInstance = RefreshControl;

export default RefreshControl;
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@
* @format
*/

import type {HostInstance} from '../../../src/private/types/HostInstance';

Check warning on line 11 in packages/react-native/Libraries/Components/SafeAreaView/SafeAreaView.js

View workflow job for this annotation

GitHub Actions / test_js (24)

Requires should be sorted alphabetically, with at least one line between imports/requires and code

Check warning on line 11 in packages/react-native/Libraries/Components/SafeAreaView/SafeAreaView.js

View workflow job for this annotation

GitHub Actions / test_js (22.13.0)

Requires should be sorted alphabetically, with at least one line between imports/requires and code
import type {ViewProps} from '../View/ViewPropTypes';

export type SafeAreaViewInstance = HostInstance;

import Platform from '../../Utilities/Platform';
import View from '../View/View';
import * as React from 'react';
Expand Down
46 changes: 23 additions & 23 deletions packages/react-native/Libraries/Components/ScrollView/ScrollView.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ export interface ScrollViewImperativeMethods {
readonly getScrollableNode: () => ?number;
readonly getInnerViewNode: () => ?number;
readonly getInnerViewRef: () => InnerViewInstance | null;
readonly getNativeScrollRef: () => PublicScrollViewInstance | null;
readonly getNativeScrollRef: () => ScrollViewInstance | null;
readonly scrollTo: (
options?: ScrollViewScrollToOptions | number,
deprecatedX?: number,
Expand Down Expand Up @@ -167,10 +167,13 @@ export interface ScrollViewImperativeMethods {
export type DecelerationRateType = 'fast' | 'normal' | number;
export type ScrollResponderType = ScrollViewImperativeMethods;

export interface PublicScrollViewInstance
export interface ScrollViewInstance
extends HostInstance,
ScrollViewImperativeMethods {}

/** @deprecated Use ScrollViewInstance instead */
export type PublicScrollViewInstance = ScrollViewInstance;

type InnerViewInstance = React.ElementRef<typeof View>;

export type ScrollViewPropsIOS = Readonly<{
Expand Down Expand Up @@ -677,7 +680,7 @@ type ScrollViewBaseProps = Readonly<{
* all of ScrollView's public methods, in addition to native methods like
* measure, measureLayout, etc.
*/
scrollViewRef?: React.RefSetter<PublicScrollViewInstance>,
scrollViewRef?: React.RefSetter<ScrollViewInstance>,
}>;

/** @build-types emit-as-interface Nativewind compatibility */
Expand Down Expand Up @@ -874,7 +877,7 @@ class ScrollView extends React.Component<ScrollViewProps, ScrollViewState> {
getNativeScrollRef: ScrollViewImperativeMethods['getNativeScrollRef'] =
() => {
// Object.assign in _scrollView's mutator augments nativeInstance in place,
// so it is already a PublicScrollViewInstance at runtime.
// so it is already a ScrollViewInstance at runtime.
// $FlowFixMe[incompatible-type]
return this._scrollView.nativeInstance;
};
Expand Down Expand Up @@ -1170,7 +1173,7 @@ class ScrollView extends React.Component<ScrollViewProps, ScrollViewState> {
(instance: InnerViewInstance): InnerViewInstance => instance,
);

_scrollView: RefForwarder<HostInstance, PublicScrollViewInstance | null> =
_scrollView: RefForwarder<HostInstance, ScrollViewInstance | null> =
createRefForwarder(nativeInstance => {
// This is a hack. Ideally we would forwardRef to the underlying
// host component. However, since ScrollView has it's own methods that can be
Expand All @@ -1183,22 +1186,19 @@ class ScrollView extends React.Component<ScrollViewProps, ScrollViewState> {
// $FlowFixMe[prop-missing] - Known issue with appending custom methods.
// $FlowFixMe[incompatible-type]
// $FlowFixMe[unsafe-object-assign]
const publicInstance: PublicScrollViewInstance = Object.assign(
nativeInstance,
{
getScrollResponder: this.getScrollResponder,
getScrollableNode: this.getScrollableNode,
getInnerViewNode: this.getInnerViewNode,
getInnerViewRef: this.getInnerViewRef,
getNativeScrollRef: this.getNativeScrollRef,
scrollTo: this.scrollTo,
scrollToEnd: this.scrollToEnd,
flashScrollIndicators: this.flashScrollIndicators,
scrollResponderZoomTo: this.scrollResponderZoomTo,
scrollResponderScrollNativeHandleToKeyboard:
this.scrollResponderScrollNativeHandleToKeyboard,
},
);
const publicInstance: ScrollViewInstance = Object.assign(nativeInstance, {
getScrollResponder: this.getScrollResponder,
getScrollableNode: this.getScrollableNode,
getInnerViewNode: this.getInnerViewNode,
getInnerViewRef: this.getInnerViewRef,
getNativeScrollRef: this.getNativeScrollRef,
scrollTo: this.scrollTo,
scrollToEnd: this.scrollToEnd,
flashScrollIndicators: this.flashScrollIndicators,
scrollResponderZoomTo: this.scrollResponderZoomTo,
scrollResponderScrollNativeHandleToKeyboard:
this.scrollResponderScrollNativeHandleToKeyboard,
});

return publicInstance;
});
Expand Down Expand Up @@ -1935,13 +1935,13 @@ function createRefForwarder<TNativeInstance, TPublicInstance>(
// component and we need to map `ref` to a differently named prop. This can be
// removed when `ScrollView` is a functional component.
const ScrollViewWrapper: component(
ref?: React.RefSetter<PublicScrollViewInstance>,
ref?: React.RefSetter<ScrollViewInstance>,
...props: ScrollViewProps
) = function Wrapper({
ref,
...props
}: {
ref?: React.RefSetter<PublicScrollViewInstance>,
ref?: React.RefSetter<ScrollViewInstance>,
...ScrollViewProps,
}): React.Node {
return ref == null ? (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -509,4 +509,6 @@ class StatusBar extends React.Component<StatusBarProps> {
}
}

export type StatusBarInstance = StatusBar;

export default StatusBar;
3 changes: 3 additions & 0 deletions packages/react-native/Libraries/Components/Switch/Switch.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,14 @@
* @format
*/

import type {HostInstance} from '../../../src/private/types/HostInstance';

Check warning on line 11 in packages/react-native/Libraries/Components/Switch/Switch.js

View workflow job for this annotation

GitHub Actions / test_js (24)

Requires should be sorted alphabetically, with at least one line between imports/requires and code

Check warning on line 11 in packages/react-native/Libraries/Components/Switch/Switch.js

View workflow job for this annotation

GitHub Actions / test_js (22.13.0)

Requires should be sorted alphabetically, with at least one line between imports/requires and code
import type {ColorValue} from '../../StyleSheet/StyleSheet';
import type {NativeSyntheticEvent} from '../../Types/CoreEventTypes';
import type {AccessibilityState} from '../View/ViewAccessibility';
import type {ViewProps} from '../View/ViewPropTypes';

export type SwitchInstance = HostInstance;

import StyleSheet from '../../StyleSheet/StyleSheet';
import Platform from '../../Utilities/Platform';
import useMergeRefs from '../../Utilities/useMergeRefs';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ export type {
TextInputKeyPressEvent,
TextInputProps,
TextInputSelectionChangeEvent,
TextInputInstance,
TextInputSubmitEditingEvent,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,13 @@
* @format
*/

import type {HostInstance} from '../../../src/private/types/HostInstance';

Check warning on line 11 in packages/react-native/Libraries/Components/Touchable/TouchableHighlight.js

View workflow job for this annotation

GitHub Actions / test_js (24)

Requires should be sorted alphabetically, with at least one line between imports/requires and code

Check warning on line 11 in packages/react-native/Libraries/Components/Touchable/TouchableHighlight.js

View workflow job for this annotation

GitHub Actions / test_js (22.13.0)

Requires should be sorted alphabetically, with at least one line between imports/requires and code
import type {ColorValue} from '../../StyleSheet/StyleSheet';
import type {AccessibilityState} from '../View/ViewAccessibility';
import type {TouchableWithoutFeedbackProps} from './TouchableWithoutFeedback';

export type TouchableHighlightInstance = HostInstance;

import View from '../../Components/View/View';
import Pressability, {
type PressabilityConfig,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -409,4 +409,6 @@ const getBackgroundProp =

TouchableNativeFeedback.displayName = 'TouchableNativeFeedback';

export type TouchableNativeFeedbackInstance = TouchableNativeFeedback;

export default TouchableNativeFeedback;
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,12 @@
* @format
*/

import type {HostInstance} from '../../../src/private/types/HostInstance';

Check warning on line 11 in packages/react-native/Libraries/Components/Touchable/TouchableOpacity.js

View workflow job for this annotation

GitHub Actions / test_js (24)

Requires should be sorted alphabetically, with at least one line between imports/requires and code

Check warning on line 11 in packages/react-native/Libraries/Components/Touchable/TouchableOpacity.js

View workflow job for this annotation

GitHub Actions / test_js (22.13.0)

Requires should be sorted alphabetically, with at least one line between imports/requires and code
import type {ViewStyleProp} from '../../StyleSheet/StyleSheet';
import type {TouchableWithoutFeedbackProps} from './TouchableWithoutFeedback';

export type TouchableOpacityInstance = HostInstance;

import Animated from '../../Animated/Animated';
import Easing from '../../Animated/Easing';
import Pressability, {
Expand Down
3 changes: 3 additions & 0 deletions packages/react-native/Libraries/Components/View/View.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,13 @@
* @format
*/

import type {HostInstance} from '../../../src/private/types/HostInstance';

Check warning on line 11 in packages/react-native/Libraries/Components/View/View.js

View workflow job for this annotation

GitHub Actions / test_js (24)

Requires should be sorted alphabetically, with at least one line between imports/requires and code

Check warning on line 11 in packages/react-native/Libraries/Components/View/View.js

View workflow job for this annotation

GitHub Actions / test_js (22.13.0)

Requires should be sorted alphabetically, with at least one line between imports/requires and code
import type {ViewProps} from './ViewPropTypes';

import TextAncestorContext from '../../Text/TextAncestorContext';
import ViewNativeComponent from './ViewNativeComponent';

export type ViewInstance = HostInstance;
import * as React from 'react';
import {use} from 'react';

Expand Down
2 changes: 2 additions & 0 deletions packages/react-native/Libraries/Image/Image.android.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@
* @format
*/

import type {HostInstance} from '../../src/private/types/HostInstance';

Check warning on line 11 in packages/react-native/Libraries/Image/Image.android.js

View workflow job for this annotation

GitHub Actions / test_js (24)

Requires should be sorted alphabetically, with at least one line between imports/requires and code

Check warning on line 11 in packages/react-native/Libraries/Image/Image.android.js

View workflow job for this annotation

GitHub Actions / test_js (22.13.0)

Requires should be sorted alphabetically, with at least one line between imports/requires and code
import type {ImageStyleProp} from '../StyleSheet/StyleSheet';
import type {RootTag} from '../Types/RootTagTypes';
import type {ImageProps} from './ImageProps';
import type {AbstractImageAndroid, ImageAndroid} from './ImageTypes.flow';

export type ImageInstance = HostInstance;

import flattenStyle from '../StyleSheet/flattenStyle';
import StyleSheet from '../StyleSheet/StyleSheet';
import ImageAnalyticsTagContext from './ImageAnalyticsTagContext';
Expand Down
2 changes: 2 additions & 0 deletions packages/react-native/Libraries/Image/Image.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@
* @format
*/

import type {HostInstance} from '../../src/private/types/HostInstance';

Check warning on line 11 in packages/react-native/Libraries/Image/Image.ios.js

View workflow job for this annotation

GitHub Actions / test_js (24)

Requires should be sorted alphabetically, with at least one line between imports/requires and code

Check warning on line 11 in packages/react-native/Libraries/Image/Image.ios.js

View workflow job for this annotation

GitHub Actions / test_js (22.13.0)

Requires should be sorted alphabetically, with at least one line between imports/requires and code
import type {ImageStyleProp} from '../StyleSheet/StyleSheet';
import type {RootTag} from '../Types/RootTagTypes';
import type {ImageProps} from './ImageProps';
import type {AbstractImageIOS, ImageIOS} from './ImageTypes.flow';
import type {ImageSize} from './NativeImageLoaderAndroid';

export type ImageInstance = HostInstance;

import {createRootTag} from '../ReactNative/RootTag';
import flattenStyle from '../StyleSheet/flattenStyle';
import StyleSheet from '../StyleSheet/StyleSheet';
Expand Down
2 changes: 2 additions & 0 deletions packages/react-native/Libraries/Image/ImageBackground.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,4 +105,6 @@ class ImageBackground extends React.Component<ImageBackgroundProps> {
}
}

export type ImageBackgroundInstance = ImageBackground;

export default ImageBackground;
2 changes: 2 additions & 0 deletions packages/react-native/Libraries/Image/ImageTypes.flow.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

import type {HostInstance} from '../..';
import type {RootTag} from '../Types/RootTagTypes';

export type ImageInstance = HostInstance;
import type {ResolvedAssetSource} from './AssetSourceResolver';
import type {ImageProps as ImagePropsType} from './ImageProps';
import type {ImageSource} from './ImageSource';
Expand Down
6 changes: 4 additions & 2 deletions packages/react-native/Libraries/Lists/FlatList.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* @format
*/

import type {PublicScrollViewInstance} from '../Components/ScrollView/ScrollView';
import type {ScrollViewInstance} from '../Components/ScrollView/ScrollView';
import type {ViewStyleProp} from '../StyleSheet/StyleSheet';
import type {
ListRenderItem,
Expand Down Expand Up @@ -398,7 +398,7 @@ class FlatList<ItemT = any> extends React.PureComponent<FlatListProps<ItemT>> {
/**
* Provides a reference to the underlying host component
*/
getNativeScrollRef(): ?PublicScrollViewInstance {
getNativeScrollRef(): ?ScrollViewInstance {
if (this._listRef) {
return this._listRef.getScrollRef();
}
Expand Down Expand Up @@ -706,4 +706,6 @@ const styles = StyleSheet.create({
row: {flexDirection: 'row'},
});

export type FlatListInstance = FlatList<>;

export default FlatList;
2 changes: 2 additions & 0 deletions packages/react-native/Libraries/Lists/SectionList.js
Original file line number Diff line number Diff line change
Expand Up @@ -265,3 +265,5 @@ export default class SectionList<
this._wrapperListRef = ref;
};
}

export type SectionListInstance = SectionList<>;
3 changes: 3 additions & 0 deletions packages/react-native/Libraries/Lists/VirtualizedList.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,14 @@
'use strict';

import VirtualizedLists from '@react-native/virtualized-lists';
import * as React from 'react';

type VirtualizedListType = typeof VirtualizedLists.VirtualizedList;
const VirtualizedListComponent: VirtualizedListType =
VirtualizedLists.VirtualizedList;

export type VirtualizedListInstance = React.ElementRef<VirtualizedListType>;

export type {
ListRenderItemInfo,
ListRenderItem,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,16 @@
'use strict';

import VirtualizedLists from '@react-native/virtualized-lists';
import * as React from 'react';

type VirtualizedSectionListType =
typeof VirtualizedLists.VirtualizedSectionList;
const VirtualizedSectionList: VirtualizedSectionListType =
VirtualizedLists.VirtualizedSectionList;

export type VirtualizedSectionListInstance =
React.ElementRef<VirtualizedSectionListType>;

export type {
SectionBase,
ScrollToLocationParamsType,
Expand Down
Loading
Loading