Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TS migration] Migrate 'OptionRow.js' component to TypeScript #33077

Merged
merged 14 commits into from
Dec 29, 2023
Merged
Show file tree
Hide file tree
Changes from 5 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
1 change: 1 addition & 0 deletions src/components/Icon/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,4 @@ class Icon extends PureComponent<IconProps> {
}

export default withTheme(withThemeStyles(withStyleUtils(Icon)));
export type {SrcProps};
VickyStash marked this conversation as resolved.
Show resolved Hide resolved
6 changes: 3 additions & 3 deletions src/components/OfflineWithFeedback.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ import MessagesRow from './MessagesRow';

type OfflineWithFeedbackProps = ChildrenProps & {
/** The type of action that's pending */
pendingAction: OnyxCommon.PendingAction;
pendingAction?: OnyxCommon.PendingAction;

/** Determine whether to hide the component's children if deletion is pending */
shouldHideOnDelete?: boolean;

/** The errors to display */
errors?: OnyxCommon.Errors;
errors?: OnyxCommon.Errors | null;

/** Whether we should show the error messages */
shouldShowErrorMessages?: boolean;
Expand Down Expand Up @@ -56,7 +56,7 @@ type OfflineWithFeedbackProps = ChildrenProps & {

type StrikethroughProps = Partial<ChildrenProps> & {style: Array<ViewStyle | TextStyle | ImageStyle>};

function omitBy<T>(obj: Record<string, T> | undefined, predicate: (value: T) => boolean) {
function omitBy<T>(obj: Record<string, T> | undefined | null, predicate: (value: T) => boolean) {
// eslint-disable-next-line @typescript-eslint/naming-convention, @typescript-eslint/no-unused-vars
return Object.fromEntries(Object.entries(obj ?? {}).filter(([_, value]) => !predicate(value)));
}
Expand Down
239 changes: 114 additions & 125 deletions src/components/OptionRow.js → src/components/OptionRow.tsx

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/components/Pressable/GenericPressable/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ type RequiredAccessibilityLabel =
* @example 'Search'
* @example 'Close'
*/
accessibilityLabel: string;
accessibilityLabel?: string;
VickyStash marked this conversation as resolved.
Show resolved Hide resolved
}
| {
/**
Expand Down
1 change: 1 addition & 0 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ export default {
add: 'Add',
resend: 'Resend',
save: 'Save',
select: 'Select',
saveChanges: 'Save changes',
submit: 'Submit',
rotate: 'Rotate',
Expand Down
1 change: 1 addition & 0 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ export default {
optional: 'Opcional',
new: 'Nuevo',
search: 'Buscar',
select: 'Seleccionar',
next: 'Siguiente',
previous: 'Anterior',
goBack: 'Volver',
Expand Down
13 changes: 12 additions & 1 deletion src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import React from 'react';
import Onyx, {OnyxCollection, OnyxEntry, OnyxUpdate} from 'react-native-onyx';
import {SvgProps} from 'react-native-svg';
import {ValueOf} from 'type-fest';
import type {SrcProps} from '@components/Icon';
import * as Expensicons from '@components/Icon/Expensicons';
import * as defaultWorkspaceAvatars from '@components/Icon/WorkspaceDefaultAvatars';
import CONST from '@src/CONST';
Expand Down Expand Up @@ -312,14 +313,24 @@ type OptimisticIOUReport = Pick<
>;
type DisplayNameWithTooltips = Array<Pick<PersonalDetails, 'accountID' | 'pronouns' | 'displayName' | 'login' | 'avatar'>>;

type CustomIcon = {
src: (props: SrcProps) => React.ReactNode;
color?: string;
};

type OptionData = {
alternateText?: string | null;
allReportErrors?: Errors | null;
brickRoadIndicator?: typeof CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR | '' | null;
tooltipText?: string | null;
alternateTextMaxLines?: number;
boldStyle?: boolean;
customIcon?: CustomIcon;
descriptiveText?: string;
subtitle?: string | null;
login?: string | null;
accountID?: number | null;
pronouns?: string;
status?: string | null;
phoneNumber?: string | null;
isUnread?: boolean | null;
Expand Down Expand Up @@ -1449,7 +1460,7 @@ function getDisplayNameForParticipant(accountID?: number, shouldUseShortForm = f
}

function getDisplayNamesWithTooltips(
personalDetailsList: PersonalDetails[] | PersonalDetailsList,
personalDetailsList: PersonalDetails[] | PersonalDetailsList | OptionData[],
isMultipleParticipantReport: boolean,
shouldFallbackToHidden = true,
): DisplayNameWithTooltips {
Expand Down
2 changes: 1 addition & 1 deletion src/styles/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ function getWidthStyle(width: number): ViewStyle {
/**
* Returns a style with backgroundColor and borderColor set to the same color
*/
function getBackgroundAndBorderStyle(backgroundColor: string): ViewStyle {
function getBackgroundAndBorderStyle(backgroundColor: string | undefined): ViewStyle {
return {
backgroundColor,
borderColor: backgroundColor,
Expand Down
2 changes: 1 addition & 1 deletion src/types/onyx/Report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ type Report = {
nonReimbursableTotal?: number;
isHidden?: boolean;
isChatRoom?: boolean;
participantsList?: Array<Partial<PersonalDetails>>;
participantsList?: PersonalDetails[];
text?: string;
privateNotes?: Record<number, Note>;
isLoadingPrivateNotes?: boolean;
Expand Down
Loading