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 RoomInvitePage to typescript #34956

Merged
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
4 changes: 3 additions & 1 deletion src/libs/Navigation/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,9 @@ type RoomMembersNavigatorParamList = {
};

type RoomInviteNavigatorParamList = {
[SCREENS.ROOM_INVITE_ROOT]: undefined;
[SCREENS.ROOM_INVITE_ROOT]: {
reportID: string;
};
};

type MoneyRequestNavigatorParamList = {
Expand Down
22 changes: 7 additions & 15 deletions src/libs/OptionsListUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import lodashGet from 'lodash/get';
import lodashOrderBy from 'lodash/orderBy';
import lodashSet from 'lodash/set';
import lodashSortBy from 'lodash/sortBy';
import type {ReactElement} from 'react';
import Onyx from 'react-native-onyx';
import type {OnyxCollection, OnyxEntry} from 'react-native-onyx';
import CONST from '@src/CONST';
Expand Down Expand Up @@ -122,11 +121,11 @@ type MemberForList = {
keyForList: string;
isSelected: boolean;
isDisabled: boolean;
accountID?: number;
accountID?: number | null;
login: string;
rightElement: ReactElement | null;
icons?: OnyxCommon.Icon[];
pendingAction?: OnyxCommon.PendingAction;
reportID: string;
};

type SectionForSearchTerm = {
Expand Down Expand Up @@ -1837,14 +1836,8 @@ function getShareDestinationOptions(
* @param member - personalDetails or userToInvite
* @param config - keys to overwrite the default values
*/
function formatMemberForList(member: ReportUtils.OptionData, config?: Partial<MemberForList>): MemberForList;
function formatMemberForList(member: null | undefined, config?: Partial<MemberForList>): undefined;
function formatMemberForList(member: ReportUtils.OptionData | null | undefined, config: Partial<MemberForList> = {}): MemberForList | undefined {
if (!member) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we have any case where this could error?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above, every usage of this function has member of ReportUtils.OptionData type, not undefined or null, so we don't need this check. Future usages are going to be checked by typecheck.

return undefined;
}

const accountID = member.accountID ?? undefined;
function formatMemberForList(member: ReportUtils.OptionData): MemberForList {
const accountID = member.accountID;

return {
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
Expand All @@ -1853,14 +1846,13 @@ function formatMemberForList(member: ReportUtils.OptionData | null | undefined,
alternateText: member.alternateText || member.login || '',
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
keyForList: member.keyForList || String(accountID ?? 0) || '',
isSelected: false,
isDisabled: false,
isSelected: member.isSelected ?? false,
isDisabled: member.isDisabled ?? false,
accountID,
login: member.login ?? '',
rightElement: null,
icons: member.icons,
pendingAction: member.pendingAction,
...config,
reportID: member.reportID,
};
}

Expand Down
2 changes: 2 additions & 0 deletions src/libs/PolicyUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -263,3 +263,5 @@ export {
getPathWithoutPolicyID,
getPolicyMembersByIdWithoutCurrentUser,
};

export type {MemberEmailsToAccountIDs};
Loading
Loading