diff --git a/native/account/registration/registration-text-input.react.js b/native/account/registration/registration-text-input.react.js --- a/native/account/registration/registration-text-input.react.js +++ b/native/account/registration/registration-text-input.react.js @@ -86,10 +86,15 @@ }, }; -const RegistrationTextInput: React.ComponentType = React.forwardRef< - Props, - React.ElementRef, ->(ForwardedRegistrationTextInput); +type RegistrationTextInputComponentType = component( + ref: React.RefSetter>, + ...Props +); + +const RegistrationTextInput: RegistrationTextInputComponentType = + React.forwardRef>( + ForwardedRegistrationTextInput, + ); RegistrationTextInput.displayName = 'RegistrationTextInput'; const MemoizedRegistrationTextInput: typeof RegistrationTextInput = React.memo< diff --git a/native/bottom-sheet/bottom-sheet.react.js b/native/bottom-sheet/bottom-sheet.react.js --- a/native/bottom-sheet/bottom-sheet.react.js +++ b/native/bottom-sheet/bottom-sheet.react.js @@ -9,6 +9,7 @@ import BottomSheetHandle from './bottom-sheet-handle.react.js'; import { BottomSheetContext } from './bottom-sheet-provider.react.js'; import { useStyles } from '../themes/colors.js'; +import type { BottomSheetRef } from '../types/bottom-sheet.js'; type Props = { +children: React.Node, @@ -63,7 +64,12 @@ }, }; -const BottomSheet: React.ComponentType = React.forwardRef< +type BottomSheetComponentType = component( + ref: React.RefSetter, + ...Props +); + +const BottomSheet: BottomSheetComponentType = React.forwardRef< Props, React.ElementRef, >(ForwardedBottomSheet); diff --git a/native/chat/chat-input-bar.react.js b/native/chat/chat-input-bar.react.js --- a/native/chat/chat-input-bar.react.js +++ b/native/chat/chat-input-bar.react.js @@ -79,7 +79,10 @@ import Button from '../components/button.react.js'; // eslint-disable-next-line import/extensions import ClearableTextInput from '../components/clearable-text-input.react'; -import type { SyncedSelectionData } from '../components/selectable-text-input.js'; +import type { + SyncedSelectionData, + SelectableTextInputRef, +} from '../components/selectable-text-input.js'; // eslint-disable-next-line import/extensions import SelectableTextInput from '../components/selectable-text-input.react'; import SingleLine from '../components/single-line.react.js'; @@ -500,8 +503,7 @@ const textInputRef = React.useRef>(); const clearableTextInputRef = React.useRef(); - const selectableTextInputRef = - React.useRef>(); + const selectableTextInputRef = React.useRef(); const setTextInputRef = React.useCallback( (ref: ?React.ElementRef) => { textInputRef.current = ref; diff --git a/native/chat/chat-thread-list-search.react.js b/native/chat/chat-thread-list-search.react.js --- a/native/chat/chat-thread-list-search.react.js +++ b/native/chat/chat-thread-list-search.react.js @@ -154,10 +154,15 @@ }, }; -const ChatThreadListSearch: React.ComponentType = React.forwardRef< - Props, - React.ElementRef, ->(ForwardedChatThreadListSearch); +type ChatThreadListSearchComponentType = component( + ref: React.RefSetter>, + ...Props +); + +const ChatThreadListSearch: ChatThreadListSearchComponentType = + React.forwardRef>( + ForwardedChatThreadListSearch, + ); ChatThreadListSearch.displayName = 'ChatThreadListSearch'; export default ChatThreadListSearch; diff --git a/native/components/directory-prompt-bottom-sheet.react.js b/native/components/directory-prompt-bottom-sheet.react.js --- a/native/components/directory-prompt-bottom-sheet.react.js +++ b/native/components/directory-prompt-bottom-sheet.react.js @@ -18,6 +18,7 @@ type NavigationRoute, NUXTipOverlayBackdropRouteName, } from '../navigation/route-names.js'; +import type { BottomSheetRef } from '../types/bottom-sheet.js'; export type DirectoryPromptBottomSheetParams = { +communities: $ReadOnlyArray, @@ -39,7 +40,7 @@ const { goBack, navigate } = navigation; const { communities } = route.params; - const bottomSheetRef = React.useRef(null); + const bottomSheetRef = React.useRef(null); const bottomSheetContext = React.useContext(BottomSheetContext); invariant(bottomSheetContext, 'bottomSheetContext should be set'); diff --git a/native/components/full-screen-view-modal.react.js b/native/components/full-screen-view-modal.react.js --- a/native/components/full-screen-view-modal.react.js +++ b/native/components/full-screen-view-modal.react.js @@ -9,6 +9,7 @@ TouchableOpacity, Platform, } from 'react-native'; +import type { LegacyHostInstanceMethods } from 'react-native/src/private/types/HostInstance'; import { type PinchGestureEvent, type PanGestureEvent, @@ -44,7 +45,6 @@ import type { NavigationRoute } from '../navigation/route-names.js'; import { useSelector } from '../redux/redux-utils.js'; import { derivedDimensionsInfoSelector } from '../selectors/dimensions-selectors.js'; -import type { NativeMethods } from '../types/react-native.js'; import type { UserProfileBottomSheetNavigationProp } from '../user-profile/user-profile-bottom-sheet-navigator.react.js'; import { clamp } from '../utils/animation-utils.js'; @@ -55,10 +55,6 @@ const decayConfig = { deceleration: 0.99 }; -type TouchableOpacityInstance = React.ComponentType< - React.ElementConfig, ->; - type ButtonDimensions = { +x: number, +y: number, @@ -129,7 +125,7 @@ ); const closeButtonRef = - React.useRef>(); + React.useRef>(); const mediaIconsRef = React.useRef>(); const closeButtonDimensions = useSharedValue({ @@ -154,9 +150,11 @@ if (!closeButton) { return; } - closeButton.measure((x, y, width, height, pageX, pageY) => { - closeButtonDimensions.value = { x: pageX, y: pageY, width, height }; - }); + ((closeButton: any): LegacyHostInstanceMethods).measure( + (x, y, width, height, pageX, pageY) => { + closeButtonDimensions.value = { x: pageX, y: pageY, width, height }; + }, + ); }, [closeButtonDimensions]); const onMediaIconsLayout = React.useCallback(() => { @@ -165,9 +163,11 @@ return; } - mediaIconsContainer.measure((x, y, width, height, pageX, pageY) => { - mediaIconsDimensions.value = { x: pageX, y: pageY, width, height }; - }); + ((mediaIconsContainer: any): LegacyHostInstanceMethods).measure( + (x, y, width, height, pageX, pageY) => { + mediaIconsDimensions.value = { x: pageX, y: pageY, width, height }; + }, + ); }, [mediaIconsDimensions]); const insets = useSafeAreaInsets(); diff --git a/native/components/search.react.js b/native/components/search.react.js --- a/native/components/search.react.js +++ b/native/components/search.react.js @@ -102,10 +102,14 @@ ); } -const Search: React.ComponentType = React.forwardRef< - Props, - React.ElementRef, ->(ForwardedSearch); +type SearchComponentType = component( + ref: React.RefSetter>, + ...Props +); + +const Search = React.forwardRef>( + ForwardedSearch, +); Search.displayName = 'Search'; const unboundStyles = { @@ -138,7 +142,7 @@ }, }; -const MemoizedSearch: typeof Search = React.memo< +const MemoizedSearch: SearchComponentType = React.memo< Props, React.ElementRef, >(Search); diff --git a/native/components/selectable-text-input.react.ios.js b/native/components/selectable-text-input.react.ios.js --- a/native/components/selectable-text-input.react.ios.js +++ b/native/components/selectable-text-input.react.ios.js @@ -131,7 +131,12 @@ ); }); -const MemoizedSelectableTextInput: React.ComponentType = +type MemoizedSelectableTextInputComponent = component( + ref: React.RefSetter, + ...SelectableTextInputProps +); + +const MemoizedSelectableTextInput: MemoizedSelectableTextInputComponent = React.memo( SelectableTextInput, ); diff --git a/native/components/selectable-text-input.react.js b/native/components/selectable-text-input.react.js --- a/native/components/selectable-text-input.react.js +++ b/native/components/selectable-text-input.react.js @@ -76,7 +76,12 @@ ); }); -const MemoizedSelectableTextInput: React.ComponentType = +type MemoizedSelectableTextInputComponent = component( + ref: React.RefSetter, + ...SelectableTextInputProps +); + +const MemoizedSelectableTextInput: MemoizedSelectableTextInputComponent = React.memo( SelectableTextInput, ); diff --git a/native/components/tag-input.react.js b/native/components/tag-input.react.js --- a/native/components/tag-input.react.js +++ b/native/components/tag-input.react.js @@ -459,7 +459,12 @@ typeof BaseTagInput.defaultProps, >; -function createTagInput(): React.ComponentType> { +type TagInputComponentType = component( + ref: React.RefSetter>, + ...BaseConfig +); + +function createTagInput(): TagInputComponentType { return React.forwardRef, BaseTagInput>( function ForwardedTagInput( props: BaseConfig, diff --git a/native/components/text-input.react.js b/native/components/text-input.react.js --- a/native/components/text-input.react.js +++ b/native/components/text-input.react.js @@ -16,7 +16,12 @@ ); } -const WrappedTextInput: React.ComponentType = React.forwardRef< +type WrappedTextInputComponentType = component( + ref: React.RefSetter>, + ...Props +); + +const WrappedTextInput: WrappedTextInputComponentType = React.forwardRef< Props, React.ElementRef, >(ForwardedTextInput); diff --git a/native/media/camera-modal.react.js b/native/media/camera-modal.react.js --- a/native/media/camera-modal.react.js +++ b/native/media/camera-modal.react.js @@ -13,6 +13,7 @@ Animated, Easing, } from 'react-native'; +import type { LegacyHostInstanceMethods } from 'react-native/src/private/types/HostInstance'; import filesystem from 'react-native-fs'; import { Gesture, GestureDetector } from 'react-native-gesture-handler'; import Orientation from 'react-native-orientation-locker'; @@ -94,10 +95,6 @@ } catch (e) {} } -type TouchableOpacityInstance = React.ComponentType< - React.ElementConfig, ->; - type Dimensions = { +x: number, +y: number, @@ -441,7 +438,7 @@ }, []); const closeButtonRef = - React.useRef>(); + React.useRef>(); const closeButtonDimensions = useSharedValue({ x: -1, y: -1, @@ -450,7 +447,7 @@ }); const photoButtonRef = - React.useRef>(); + React.useRef>(); const photoButtonDimensions = useSharedValue({ x: -1, y: -1, @@ -459,7 +456,7 @@ }); const switchCameraButtonRef = - React.useRef>(); + React.useRef>(); const switchCameraButtonDimensions = useSharedValue({ x: -1, y: -1, @@ -468,7 +465,7 @@ }); const flashButtonRef = - React.useRef>(); + React.useRef>(); const flashButtonDimensions = useSharedValue({ x: -1, y: -1, @@ -480,25 +477,29 @@ if (!closeButtonRef.current) { return; } - closeButtonRef.current.measure((x, y, width, height, pageX, pageY) => { - closeButtonDimensions.value = { x: pageX, y: pageY, width, height }; - }); + ((closeButtonRef.current: any): LegacyHostInstanceMethods).measure( + (x, y, width, height, pageX, pageY) => { + closeButtonDimensions.value = { x: pageX, y: pageY, width, height }; + }, + ); }, [closeButtonDimensions]); const onPhotoButtonLayout = React.useCallback(() => { if (!photoButtonRef.current) { return; } - photoButtonRef.current.measure((x, y, width, height, pageX, pageY) => { - photoButtonDimensions.value = { x: pageX, y: pageY, width, height }; - }); + ((photoButtonRef.current: any): LegacyHostInstanceMethods).measure( + (x, y, width, height, pageX, pageY) => { + photoButtonDimensions.value = { x: pageX, y: pageY, width, height }; + }, + ); }, [photoButtonDimensions]); const onSwitchCameraButtonLayout = React.useCallback(() => { if (!switchCameraButtonRef.current) { return; } - switchCameraButtonRef.current.measure( + ((switchCameraButtonRef.current: any): LegacyHostInstanceMethods).measure( (x, y, width, height, pageX, pageY) => { switchCameraButtonDimensions.value = { x: pageX, @@ -525,9 +526,11 @@ if (!flashButtonRef.current) { return; } - flashButtonRef.current.measure((x, y, width, height, pageX, pageY) => { - flashButtonDimensions.value = { x: pageX, y: pageY, width, height }; - }); + ((flashButtonRef.current: any): LegacyHostInstanceMethods).measure( + (x, y, width, height, pageX, pageY) => { + flashButtonDimensions.value = { x: pageX, y: pageY, width, height }; + }, + ); }, [flashButtonDimensions]); const insets = useSafeAreaInsets(); diff --git a/native/media/video-playback-modal.react.js b/native/media/video-playback-modal.react.js --- a/native/media/video-playback-modal.react.js +++ b/native/media/video-playback-modal.react.js @@ -40,11 +40,6 @@ VerticalBounds, LayoutCoordinates, } from '../types/layout-types.js'; -import type { NativeMethods } from '../types/react-native.js'; - -type TouchableOpacityInstance = React.ComponentType< - React.ElementConfig, ->; type VideoRef = { +seek: number => mixed, @@ -134,8 +129,7 @@ const closeButtonY = useSharedValue(-1); const closeButtonWidth = useSharedValue(-1); const closeButtonHeight = useSharedValue(-1); - const closeButtonRef = - React.useRef>(); + const closeButtonRef = React.useRef>(); const closeButton = closeButtonRef.current; const onCloseButtonLayoutCalledRef = React.useRef(false); const onCloseButtonLayout = React.useCallback(() => { diff --git a/web/account/password-input.react.js b/web/account/password-input.react.js --- a/web/account/password-input.react.js +++ b/web/account/password-input.react.js @@ -41,8 +41,12 @@ ); } +type ForwardedPasswordInputComponentType = component( + ref: React.RefSetter, + ...PasswordInputProps +); -const ForwardedPasswordInput: React.ComponentType = +const ForwardedPasswordInput: ForwardedPasswordInputComponentType = React.forwardRef(PasswordInput); export default ForwardedPasswordInput; diff --git a/web/components/search.react.js b/web/components/search.react.js --- a/web/components/search.react.js +++ b/web/components/search.react.js @@ -58,7 +58,12 @@ ); } -const ForwardedSearch: React.ComponentType = React.forwardRef< +type ForwardedSearchComponentType = component( + ref: React.RefSetter, + ...Props +); + +const ForwardedSearch: ForwardedSearchComponentType = React.forwardRef< Props, HTMLInputElement, >(Search); diff --git a/web/media/loadable-video.react.js b/web/media/loadable-video.react.js --- a/web/media/loadable-video.react.js +++ b/web/media/loadable-video.react.js @@ -23,7 +23,10 @@ +multimediaClassName?: string, }; -function LoadableVideo(props: Props, videoRef: React.Ref<'video'>): React.Node { +function LoadableVideo( + props: Props, + videoRef: React.RefSetter, +): React.Node { const { uri, thumbHashDataURL, @@ -97,7 +100,12 @@ ); } -const MemoizedLoadableVideo: React.ComponentType = React.memo< +type MemoizedLoadableVideoComponentType = component( + ref: React.RefSetter, + ...Props +); + +const MemoizedLoadableVideo: MemoizedLoadableVideoComponentType = React.memo< Props, HTMLVideoElement, >(React.forwardRef(LoadableVideo)); diff --git a/web/modals/input.react.js b/web/modals/input.react.js --- a/web/modals/input.react.js +++ b/web/modals/input.react.js @@ -59,7 +59,12 @@ ); } -const ForwardedInput: React.ComponentType = React.forwardRef< +type ForwardedInputComponentType = component( + ref: React.RefSetter, + ...InputProps +); + +const ForwardedInput: ForwardedInputComponentType = React.forwardRef< InputProps, HTMLInputElement, >(Input);