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
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ import {subscribeToNewActionEvent} from '@userActions/Report/reportActionSubscri
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import type * as OnyxTypes from '@src/types/onyx';
import type {ViewToken} from '@src/types/utils/ReactNativeCompat';

import type {LayoutChangeEvent, NativeScrollEvent, NativeSyntheticEvent, ViewToken} from 'react-native';
import type {LayoutChangeEvent, NativeScrollEvent, NativeSyntheticEvent} from 'react-native';

import {guidedSetupAndTourStatusSelector} from '@selectors/Onboarding';
import {useEffect, useEffectEvent, useRef} from 'react';
Expand Down
3 changes: 1 addition & 2 deletions src/hooks/useThumbnailDimensions.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import CONST from '@src/CONST';

import type {StyleProp, ViewStyle} from 'react-native';
import type {DimensionValue} from 'react-native/Libraries/StyleSheet/StyleSheetTypes';
import type {DimensionValue, StyleProp, ViewStyle} from 'react-native';

import useIsInSidePanel from './useIsInSidePanel';
import useResponsiveLayout from './useResponsiveLayout';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ import type {ComposerRef, TextSelection} from '@components/Composer/types';

import useIsScrollLikelyLayoutTriggered from '@hooks/useIsScrollLikelyLayoutTriggered';

import type {TextInputScrollEvent} from '@src/types/utils/ReactNativeCompat';
// eslint-disable-next-line no-restricted-imports
import findNodeHandle from '@src/utils/findNodeHandle';

import type {RefObject} from 'react';
import type {MeasureInWindowOnSuccessCallback, TextInputScrollEvent} from 'react-native';
import type {MeasureInWindowOnSuccessCallback} from 'react-native';

import {useEffect, useRef} from 'react';
import {useFocusedInputHandler} from 'react-native-keyboard-controller';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ import useScrollToEditingReportAction from '@pages/inbox/report/useScrollToEditi

import CONST from '@src/CONST';
import type * as OnyxTypes from '@src/types/onyx';
import type {ViewToken} from '@src/types/utils/ReactNativeCompat';
Comment thread
collectioneur marked this conversation as resolved.
Resolved

import type {LayoutChangeEvent, NativeScrollEvent, NativeSyntheticEvent, ViewToken} from 'react-native';
import type {LayoutChangeEvent, NativeScrollEvent, NativeSyntheticEvent} from 'react-native';

import {useEffect, useRef} from 'react';

Expand Down Expand Up @@ -149,7 +150,7 @@ function useReportActionsListScroll({
};

const trackViewableRowIndexes = (info: {viewableItems: ViewToken[]; changed: ViewToken[]}) => {
viewableRowIndexesRef.current = new Set(info.viewableItems.map((token) => token.index).filter((index) => index !== null));
viewableRowIndexesRef.current = new Set(info.viewableItems.map((token) => token.index).filter((index) => typeof index === 'number'));
onViewableItemsChanged(info);
};

Expand Down
3 changes: 1 addition & 2 deletions src/pages/inbox/sidebar/ProfileAvatarWithIndicator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ import type {AvatarSizeName} from '@styles/utils/types';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';

import type {StyleProp} from 'react-native';
import type {ViewStyle} from 'react-native/Libraries/StyleSheet/StyleSheetTypes';
import type {StyleProp, ViewStyle} from 'react-native';

import React from 'react';
import {View} from 'react-native';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ import ROUTES, {DYNAMIC_ROUTES} from '@src/ROUTES';
import SCREENS from '@src/SCREENS';
import type {Rule} from '@src/types/onyx';

import type {GestureResponderEvent} from 'react-native';
import type {OnyxCollection} from 'react-native-onyx';
import type {GestureResponderEvent} from 'react-native/Libraries/Types/CoreEventTypes';

import React, {useCallback, useEffect, useMemo, useRef, useState} from 'react';
import {View} from 'react-native';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ import type {CurrentUserPersonalDetails} from '@src/types/onyx/PersonalDetails';
import type Policy from '@src/types/onyx/Policy';
import {isEmptyObject} from '@src/types/utils/EmptyObject';

import type {GestureResponderEvent} from 'react-native';
import type {OnyxEntry} from 'react-native-onyx';
import type {GestureResponderEvent} from 'react-native/Libraries/Types/CoreEventTypes';

import {Str} from 'expensify-common';
import React, {useEffect, useState} from 'react';
Expand Down
4 changes: 2 additions & 2 deletions src/styles/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import type {Dimensions} from '@src/types/utils/Layout';
import type Nullable from '@src/types/utils/Nullable';

// eslint-disable-next-line no-restricted-imports
import type {AnimatableNumericValue, Animated, ColorValue, DimensionValue, ImageStyle, PressableStateCallbackType, StyleProp, TextStyle, ViewStyle} from 'react-native';
import type {Animated, ColorValue, DimensionValue, ImageStyle, PressableStateCallbackType, StyleProp, TextStyle, ViewStyle} from 'react-native';
import type {OnyxEntry} from 'react-native-onyx';
import type {EdgeInsets} from 'react-native-safe-area-context';
import type {ValueOf} from 'type-fest';
Expand Down Expand Up @@ -1120,7 +1120,7 @@ function getEmojiReactionBubbleTextStyle(isContextMenu = false): TextStyle {
};
}

function getTransformScaleStyle(scaleValue: AnimatableNumericValue): ViewStyle {
function getTransformScaleStyle(scaleValue: number): ViewStyle {
return {
transform: [{scale: scaleValue}],
};
Expand Down
15 changes: 10 additions & 5 deletions src/types/utils/ReactNativeCompat.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/**
* Stand-ins for root type exports the RN Strict TypeScript API removes.
* Derived from FlatList props so the same aliases typecheck on 0.86 and the Strict API.
* The generic is phantom under the Strict API: VirtualizedListProps is not generic there (`Item = any`),
* Stand-ins for type exports the RN Strict TypeScript API removes or hides behind deep imports.
* Each one is derived from a public prop or API signature so the same alias typechecks on 0.86 and the Strict API.
* The FlatList generic is phantom under the Strict API: VirtualizedListProps is not generic there (`Item = any`),
* so `T` is ignored and `viewableItems[].item` widens from `unknown` to `any` after the flip.
*/
import type {FlatListProps} from 'react-native';
import type {BackHandler, FlatListProps, TextInputProps} from 'react-native';

type ViewableItemsChanged = NonNullable<FlatListProps<unknown>['onViewableItemsChanged']>;

Expand All @@ -14,4 +14,9 @@ type ViewabilityConfig = NonNullable<FlatListProps<unknown>['viewabilityConfig']

type CellRendererProps<T> = NonNullable<FlatListProps<T>['CellRendererComponent']> extends React.ComponentType<infer P> ? P : never;

export type {CellRendererProps, ViewabilityConfig, ViewableItemsChanged, ViewToken};
type TextInputScrollEvent = Parameters<NonNullable<TextInputProps['onScroll']>>[0];

/** Only reachable through `react-native/Libraries/Utilities/BackHandler`, which the Strict API blocks */
type HardwareBackPressEvent = Parameters<Parameters<typeof BackHandler.addEventListener>[1]>[0];

export type {CellRendererProps, HardwareBackPressEvent, TextInputScrollEvent, ViewabilityConfig, ViewableItemsChanged, ViewToken};
3 changes: 1 addition & 2 deletions src/utils/findNodeHandle/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import type {Component, ComponentClass} from 'react';
import type {NodeHandle} from 'react-native/Libraries/ReactNative/RendererProxy';

/** Don't add new `findNodeHandle` usages, this is only a temporary solution. We're going to remove the function in the future */
// eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any
function findNodeHandle(componentOrHandle: null | number | Component<any, any> | ComponentClass<any>): null | NodeHandle {
function findNodeHandle(componentOrHandle: null | number | Component<any, any> | ComponentClass<any>): null | number {
// eslint-disable-next-line no-console
console.warn('findNodeHandle is not supported on web. Use the ref property of the component instead.');
return null;
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/WorkEmailOnboardingNativeBack.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ import ONYXKEYS from '@src/ONYXKEYS';
import ROUTES from '@src/ROUTES';
import SCREENS from '@src/SCREENS';
import type {Onboarding} from '@src/types/onyx';
import type {HardwareBackPressEvent} from '@src/types/utils/ReactNativeCompat';

import type {OnyxEntry} from 'react-native-onyx';
import type {HardwareBackPressEvent} from 'react-native/Libraries/Utilities/BackHandler';

import {PortalProvider} from '@gorhom/portal';
import {NavigationContainer, StackActions} from '@react-navigation/native';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {act, renderHook} from '@testing-library/react-native';
import type {DiscardChangesConfirmation} from '@hooks/useDiscardChangesConfirmation/types';
import type UseDiscardChangesConfirmationOptions from '@hooks/useDiscardChangesConfirmation/types';

import type {HardwareBackPressEvent} from 'react-native/Libraries/Utilities/BackHandler';
import type {HardwareBackPressEvent} from '@src/types/utils/ReactNativeCompat';

import {BackHandler} from 'react-native';

Expand Down
Loading