Skip to content

Commit

Permalink
type fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
lukemorawski committed Apr 12, 2024
1 parent 04e5417 commit e5a73de
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 30 deletions.
6 changes: 3 additions & 3 deletions src/components/SelectionList/InviteMemberListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import useTheme from '@hooks/useTheme';
import useThemeStyles from '@hooks/useThemeStyles';
import CONST from '@src/CONST';
import BaseListItem from './BaseListItem';
import type {InviteMemberListItemProps} from './types';
import type {InviteMemberListItemProps, ListItem} from './types';

function InviteMemberListItem({
function InviteMemberListItem<TItem extends ListItem>({
item,
isFocused,
showTooltip,
Expand All @@ -26,7 +26,7 @@ function InviteMemberListItem({
onDismissError,
shouldPreventDefaultFocusOnSelectRow,
rightHandSideComponent,
}: InviteMemberListItemProps) {
}: InviteMemberListItemProps<TItem>) {
const styles = useThemeStyles();
const theme = useTheme();
const StyleUtils = useStyleUtils();
Expand Down
6 changes: 3 additions & 3 deletions src/components/SelectionList/RadioListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import TextWithTooltip from '@components/TextWithTooltip';
import useThemeStyles from '@hooks/useThemeStyles';
import CONST from '@src/CONST';
import BaseListItem from './BaseListItem';
import type {RadioListItemProps} from './types';
import type {ListItem, RadioListItemProps} from './types';

function RadioListItem({
function RadioListItem<TItem extends ListItem>({
item,
isFocused,
showTooltip,
Expand All @@ -16,7 +16,7 @@ function RadioListItem({
shouldPreventDefaultFocusOnSelectRow,
rightHandSideComponent,
isMultilineSupported = false,
}: RadioListItemProps) {
}: RadioListItemProps<TItem>) {
const styles = useThemeStyles();
const fullTitle = isMultilineSupported ? item.text?.trimStart() : item.text;
const indentsLength = (item.text?.length ?? 0) - (fullTitle?.length ?? 0);
Expand Down
6 changes: 3 additions & 3 deletions src/components/SelectionList/TableListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import useTheme from '@hooks/useTheme';
import useThemeStyles from '@hooks/useThemeStyles';
import CONST from '@src/CONST';
import BaseListItem from './BaseListItem';
import type {TableListItemProps} from './types';
import type {ListItem, TableListItemProps} from './types';

function TableListItem({
function TableListItem<TItem extends ListItem>({
item,
isFocused,
showTooltip,
Expand All @@ -23,7 +23,7 @@ function TableListItem({
onDismissError,
shouldPreventDefaultFocusOnSelectRow,
rightHandSideComponent,
}: TableListItemProps) {
}: TableListItemProps<TItem>) {
const styles = useThemeStyles();
const theme = useTheme();
const StyleUtils = useStyleUtils();
Expand Down
6 changes: 3 additions & 3 deletions src/components/SelectionList/UserListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ import useTheme from '@hooks/useTheme';
import useThemeStyles from '@hooks/useThemeStyles';
import CONST from '@src/CONST';
import BaseListItem from './BaseListItem';
import type {UserListItemProps} from './types';
import type {ListItem, UserListItemProps} from './types';

function UserListItem({
function UserListItem<TItem extends ListItem>({
item,
isFocused,
showTooltip,
Expand All @@ -27,7 +27,7 @@ function UserListItem({
onDismissError,
shouldPreventDefaultFocusOnSelectRow,
rightHandSideComponent,
}: UserListItemProps) {
}: UserListItemProps<TItem>) {
const styles = useThemeStyles();
const theme = useTheme();
const StyleUtils = useStyleUtils();
Expand Down
16 changes: 8 additions & 8 deletions src/components/SelectionList/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import type RadioListItem from './RadioListItem';
import type TableListItem from './TableListItem';
import type UserListItem from './UserListItem';

type CommonListItemProps<TItem> = {
type CommonListItemProps<TItem extends ListItem> = {
/** Whether this item is focused (for arrow key controls) */
isFocused?: boolean;

Expand Down Expand Up @@ -116,9 +116,9 @@ type ListItem = {
brickRoadIndicator?: BrickRoad | '' | null;
};

type ListItemProps = CommonListItemProps<ListItem> & {
type ListItemProps<TItem extends ListItem> = CommonListItemProps<TItem> & {
/** The section list item */
item: ListItem;
item: TItem;

/** Additional styles to apply to text */
style?: StyleProp<TextStyle>;
Expand All @@ -140,10 +140,10 @@ type BaseListItemProps<TItem extends ListItem> = CommonListItemProps<TItem> & {
errors?: Errors | ReceiptErrors | null;
pendingAction?: PendingAction | null;
FooterComponent?: ReactElement;
children?: ReactElement<ListItemProps> | ((hovered: boolean) => ReactElement<ListItemProps>);
children?: ReactElement<ListItemProps<TItem>> | ((hovered: boolean) => ReactElement<ListItemProps<TItem>>);
};

type UserListItemProps = ListItemProps & {
type UserListItemProps<TItem extends ListItem> = ListItemProps<TItem> & {
/** Errors that this user may contain */
errors?: Errors | ReceiptErrors | null;

Expand All @@ -154,11 +154,11 @@ type UserListItemProps = ListItemProps & {
FooterComponent?: ReactElement;
};

type InviteMemberListItemProps = UserListItemProps;
type InviteMemberListItemProps<TItem extends ListItem> = UserListItemProps<TItem>;

type RadioListItemProps = ListItemProps;
type RadioListItemProps<TItem extends ListItem> = ListItemProps<TItem>;

type TableListItemProps = ListItemProps;
type TableListItemProps<TItem extends ListItem> = ListItemProps<TItem>;

type ValidListItem = typeof RadioListItem | typeof UserListItem | typeof TableListItem | typeof InviteMemberListItem;

Expand Down
17 changes: 7 additions & 10 deletions src/pages/iou/request/step/IOURequestStepParticipants.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -152,16 +152,13 @@ function IOURequestStepParticipants({
testID={IOURequestStepParticipants.displayName}
includeSafeAreaPaddingBottom={false}
>
{({didScreenTransitionEnd}) => (
<MoneyRequestParticipantsSelector
participants={isSplitRequest ? participants : []}
onParticipantsAdded={addParticipant}
onFinish={goToNextStep}
iouType={iouType}
iouRequestType={iouRequestType}
didScreenTransitionEnd={didScreenTransitionEnd}
/>
)}
<MoneyRequestParticipantsSelector
participants={isSplitRequest ? participants : []}
onParticipantsAdded={addParticipant}
onFinish={goToNextStep}
iouType={iouType}
iouRequestType={iouRequestType}
/>
</StepScreenWrapper>
);
}
Expand Down

0 comments on commit e5a73de

Please sign in to comment.