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

[No QA][TS Migration] Add comments for remaining properties in Onyx types #41956

Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
5b9433c
docs: add onyx types descriptions
pac-guerreiro May 9, 2024
4dac52f
docs: add missing onyx types descriptions
pac-guerreiro May 13, 2024
ee11f2e
Merge branch 'main' into pac-guerreiro/refactor/39129-add-comments-to…
pac-guerreiro May 13, 2024
8631fa8
Merge branch 'main' into pac-guerreiro/refactor/39129-add-comments-to…
pac-guerreiro May 15, 2024
13029ae
docs: add missing type descriptions
pac-guerreiro May 15, 2024
3494545
Merge branch 'main' into pac-guerreiro/refactor/39129-add-comments-to…
pac-guerreiro May 20, 2024
96f6955
docs: apply pull request suggestions
pac-guerreiro May 20, 2024
65022fb
refactor: apply pull request suggestions
pac-guerreiro May 22, 2024
f3e1c8f
refactor: apply pull request suggestions
pac-guerreiro May 22, 2024
530d6d6
refactor: remove unused property from wallet additional details
pac-guerreiro May 22, 2024
9a50d43
docs: add missing type description
pac-guerreiro May 22, 2024
611266d
Merge branch 'main' into pac-guerreiro/refactor/39129-add-comments-to…
pac-guerreiro May 24, 2024
a4d4102
chore: resolve pending descriptions
pac-guerreiro May 24, 2024
8025926
Merge branch 'main' into pac-guerreiro/refactor/39129-add-comments-to…
pac-guerreiro May 27, 2024
5599455
docs: apply suggestions
pac-guerreiro May 27, 2024
2d91475
docs: apply suggestions
pac-guerreiro May 27, 2024
da515a8
Merge branch 'main' into pac-guerreiro/refactor/39129-add-comments-to…
pac-guerreiro May 31, 2024
530b1ce
Merge branch 'main' into pac-guerreiro/refactor/39129-add-comments-to…
pac-guerreiro Jun 1, 2024
68ce115
refactor: apply pull request suggestions
pac-guerreiro Jun 1, 2024
279e50a
Merge branch 'main' into pac-guerreiro/refactor/39129-add-comments-to…
pac-guerreiro Jun 5, 2024
9fe6712
chore: apply pull request suggestions and address types with missing …
pac-guerreiro Jun 5, 2024
c46d709
Merge branch 'main' into pac-guerreiro/refactor/39129-add-comments-to…
pac-guerreiro Jun 5, 2024
6dabcc0
chore: enable eslint rule that requires comments on onyx types and th…
pac-guerreiro Jun 6, 2024
11090bd
Merge branch 'main' into pac-guerreiro/refactor/39129-add-comments-to…
pac-guerreiro Jun 7, 2024
453343e
refactor: apply pull request suggestions
pac-guerreiro Jun 7, 2024
98fa483
Merge branch 'main' into pac-guerreiro/refactor/39129-add-comments-to…
fabioh8010 Jun 7, 2024
a354239
Fix lint errors and improve comments
fabioh8010 Jun 7, 2024
199e228
Merge remote-tracking branch 'origin/main' into pac-guerreiro/refacto…
fabioh8010 Jun 7, 2024
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: 2 additions & 2 deletions src/libs/ModifiedExpenseMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ import type {OnyxCollection, OnyxEntry} from 'react-native-onyx';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import type {PolicyTagList, ReportAction} from '@src/types/onyx';
import type {ModifiedExpense} from '@src/types/onyx/OriginalMessage';
import * as CurrencyUtils from './CurrencyUtils';
import DateUtils from './DateUtils';
import getReportPolicyID from './getReportPolicyID';
import * as Localize from './Localize';
import * as PolicyUtils from './PolicyUtils';
import type {ExpenseOriginalMessage} from './ReportUtils';
import * as TransactionUtils from './TransactionUtils';

let allPolicyTags: OnyxCollection<PolicyTagList> = {};
Expand Down Expand Up @@ -109,7 +109,7 @@ function getForReportAction(reportID: string | undefined, reportAction: OnyxEntr
if (reportAction?.actionName !== CONST.REPORT.ACTIONS.TYPE.MODIFIED_EXPENSE) {
return '';
}
const reportActionOriginalMessage = reportAction?.originalMessage as ExpenseOriginalMessage | undefined;
const reportActionOriginalMessage = reportAction?.originalMessage as ModifiedExpense | undefined;
const policyID = getReportPolicyID(reportID) ?? '';

const removalFragments: string[] = [];
Expand Down
30 changes: 3 additions & 27 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import type {Errors, Icon, PendingAction} from '@src/types/onyx/OnyxCommon';
import type {
ChangeLog,
IOUMessage,
ModifiedExpense,
OriginalMessageActionName,
OriginalMessageCreated,
OriginalMessageDismissedViolation,
Expand Down Expand Up @@ -87,30 +88,6 @@ type AvatarRange = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |

type WelcomeMessage = {showReportName: boolean; phrase1?: string; phrase2?: string};

type ExpenseOriginalMessage = {
oldComment?: string;
newComment?: string;
comment?: string;
merchant?: string;
oldCreated?: string;
created?: string;
oldMerchant?: string;
oldAmount?: number;
amount?: number;
oldCurrency?: string;
currency?: string;
category?: string;
oldCategory?: string;
tag?: string;
oldTag?: string;
billable?: string;
oldBillable?: string;
oldTaxAmount?: number;
taxAmount?: number;
taxRate?: string;
oldTaxRate?: string;
};

type SpendBreakdown = {
nonReimbursableSpend: number;
reimbursableSpend: number;
Expand Down Expand Up @@ -2971,8 +2948,8 @@ function getModifiedExpenseOriginalMessage(
transactionChanges: TransactionChanges,
isFromExpenseReport: boolean,
policy: OnyxEntry<Policy>,
): ExpenseOriginalMessage {
const originalMessage: ExpenseOriginalMessage = {};
): ModifiedExpense {
const originalMessage: ModifiedExpense = {};
// Remark: Comment field is the only one which has new/old prefixes for the keys (newComment/ oldComment),
// all others have old/- pattern such as oldCreated/created
if ('comment' in transactionChanges) {
Expand Down Expand Up @@ -6942,7 +6919,6 @@ export {
export type {
Ancestor,
DisplayNameWithTooltips,
ExpenseOriginalMessage,
OptimisticAddCommentReportAction,
OptimisticChatReport,
OptimisticClosedReportAction,
Expand Down
6 changes: 3 additions & 3 deletions src/libs/actions/Card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type {ActivatePhysicalExpensifyCardParams, ReportVirtualExpensifyCardFrau
import {SIDE_EFFECT_REQUEST_COMMANDS, WRITE_COMMANDS} from '@libs/API/types';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import type {Response} from '@src/types/onyx';
import type {ExpensifyCardDetails} from '@src/types/onyx/Card';

type ReplacementReason = 'damaged' | 'stolen';

Expand Down Expand Up @@ -158,7 +158,7 @@ function clearCardListErrors(cardID: number) {
*
* @returns promise with card details object
*/
function revealVirtualCardDetails(cardID: number): Promise<Response> {
function revealVirtualCardDetails(cardID: number): Promise<ExpensifyCardDetails> {
return new Promise((resolve, reject) => {
const parameters: RevealExpensifyCardDetailsParams = {cardID};

Expand All @@ -170,7 +170,7 @@ function revealVirtualCardDetails(cardID: number): Promise<Response> {
reject('cardPage.cardDetailsLoadingFailure');
return;
}
resolve(response);
resolve(response as ExpensifyCardDetails);
})
// eslint-disable-next-line prefer-promise-reject-errors
.catch(() => reject('cardPage.cardDetailsLoadingFailure'));
Expand Down
5 changes: 0 additions & 5 deletions src/libs/actions/Wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,6 @@ function setAdditionalDetailsErrors(errorFields: OnyxCommon.ErrorFields) {
Onyx.merge(ONYXKEYS.WALLET_ADDITIONAL_DETAILS, {errorFields});
}

function setAdditionalDetailsErrorMessage(additionalErrorMessage: string) {
Onyx.merge(ONYXKEYS.WALLET_ADDITIONAL_DETAILS, {additionalErrorMessage});
}

/**
* Save the source that triggered the KYC wall and optionally the chat report ID associated with the IOU
*/
Expand Down Expand Up @@ -304,7 +300,6 @@ export {
openInitialSettingsPage,
openEnablePaymentsPage,
setAdditionalDetailsErrors,
setAdditionalDetailsErrorMessage,
setAdditionalDetailsQuestions,
updateCurrentStep,
answerQuestionsForWallet,
Expand Down
4 changes: 2 additions & 2 deletions src/libs/models/BankAccount.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Str from 'expensify-common/lib/str';
import type {ValueOf} from 'type-fest';
import CONST from '@src/CONST';
import type {AdditionalData} from '@src/types/onyx/BankAccount';
import type {BankAccountAdditionalData} from '@src/types/onyx/BankAccount';
import type BankAccountJSON from '@src/types/onyx/BankAccount';

type State = ValueOf<typeof BankAccount.STATE>;
Expand Down Expand Up @@ -194,7 +194,7 @@ class BankAccount {
/**
* Get the additional data of a bankAccount
*/
getAdditionalData(): Partial<AdditionalData> {
getAdditionalData(): Partial<BankAccountAdditionalData> {
return this.json.accountData?.additionalData ?? {};
}

Expand Down
6 changes: 3 additions & 3 deletions src/pages/settings/Wallet/ExpensifyCardPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import ROUTES from '@src/ROUTES';
import type SCREENS from '@src/SCREENS';
import type {GetPhysicalCardForm} from '@src/types/form';
import type {LoginList, Card as OnyxCard, PrivatePersonalDetails} from '@src/types/onyx';
import type {TCardDetails} from '@src/types/onyx/Card';
import type {ExpensifyCardDetails} from '@src/types/onyx/Card';
import RedDotCardSection from './RedDotCardSection';
import CardDetails from './WalletPage/CardDetails';

Expand Down Expand Up @@ -101,7 +101,7 @@ function ExpensifyCardPage({

const virtualCards = useMemo(() => cardsToShow?.filter((card) => card?.nameValuePairs?.isVirtual), [cardsToShow]);
const physicalCards = useMemo(() => cardsToShow?.filter((card) => !card?.nameValuePairs?.isVirtual), [cardsToShow]);
const [cardsDetails, setCardsDetails] = useState<Record<number, TCardDetails | null>>({});
const [cardsDetails, setCardsDetails] = useState<Record<number, ExpensifyCardDetails | null>>({});
const [isCardDetailsLoading, setIsCardDetailsLoading] = useState<Record<number, boolean>>({});
const [cardsDetailsErrors, setCardsDetailsErrors] = useState<Record<number, string>>({});

Expand All @@ -116,7 +116,7 @@ function ExpensifyCardPage({
// eslint-disable-next-line rulesdir/no-thenable-actions-in-views
Card.revealVirtualCardDetails(revealedCardID)
.then((value) => {
setCardsDetails((prevState: Record<number, TCardDetails | null>) => ({...prevState, [revealedCardID]: value as TCardDetails}));
setCardsDetails((prevState: Record<number, ExpensifyCardDetails | null>) => ({...prevState, [revealedCardID]: value}));
setCardsDetailsErrors((prevState) => ({
...prevState,
[revealedCardID]: '',
Expand Down
11 changes: 11 additions & 0 deletions src/types/onyx/Account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ import type DismissedReferralBanners from './DismissedReferralBanners';
import type * as OnyxCommon from './OnyxCommon';
import type {TravelSettings} from './TravelSettings';

/** Two factor authentication steps */
type TwoFactorAuthStep = ValueOf<typeof CONST.TWO_FACTOR_AUTH_STEPS> | '';

/** Model of user account */
type Account = {
/** Whether SAML is enabled for the current account */
isSAMLEnabled?: boolean;
Expand Down Expand Up @@ -55,10 +57,19 @@ type Account = {
/** Whether a sign is loading */
isLoading?: boolean;

/** Authentication failure errors */
errors?: OnyxCommon.Errors | null;

/** Authentication success message */
success?: string;

/** Whether the two factor authentication codes were copied */
codesAreCopied?: boolean;

/** Current two factor authentication step */
twoFactorAuthStep?: TwoFactorAuthStep;

/** Referral banners that the user dismissed */
dismissedReferralBanners?: DismissedReferralBanners;

/** Object containing all account information necessary to connect with Spontana */
Expand Down
16 changes: 5 additions & 11 deletions src/types/onyx/AccountData.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
import type {BankName} from './Bank';
import type {BankAccountAdditionalData} from './BankAccount';
import type * as OnyxCommon from './OnyxCommon';

type AdditionalData = {
isP2PDebitCard?: boolean;
beneficialOwners?: string[];
currency?: string;
bankName?: BankName;
fieldsType?: string;
country?: string;
};

/** Model of bank account data */
type AccountData = {
/** The masked bank account number */
accountNumber?: string;
Expand Down Expand Up @@ -38,20 +30,22 @@ type AccountData = {
/** All user emails that have access to this bank account */
sharees?: string[];

/** Institution that processes the account payments */
processor?: string;

/** The bankAccountID in the bankAccounts db */
bankAccountID?: number;

/** All data related to the bank account */
additionalData?: AdditionalData;
additionalData?: BankAccountAdditionalData;

/** The bank account type */
type?: string;

/** Any error message to show */
errors?: OnyxCommon.Errors;

/** The debit card ID */
fundID?: number;
};

Expand Down
13 changes: 13 additions & 0 deletions src/types/onyx/Bank.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,28 @@ import type {ValueOf} from 'type-fest';
import type CONST from '@src/CONST';
import type IconAsset from '@src/types/utils/IconAsset';

/** Bank icon configurations */
type BankIcon = {
/** Source of the icon, can be a component or an image */
icon: IconAsset;

/** Size of the icon */
iconSize?: number;

/** Height of the icon */
iconHeight?: number;

/** Width of the icon */
iconWidth?: number;

/** Icon wrapper styles */
iconStyles?: ViewStyle[];
};

/** Bank names */
type BankName = ValueOf<typeof CONST.BANK_NAMES>;

/** Bank name keys */
type BankNameKey = keyof typeof CONST.BANK_NAMES;

export type {BankIcon, BankName, BankNameKey};
23 changes: 19 additions & 4 deletions src/types/onyx/BankAccount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,45 @@ import type CONST from '@src/CONST';
import type AccountData from './AccountData';
import type * as OnyxCommon from './OnyxCommon';

type AdditionalData = {
/** Model of additional bank account data */
type BankAccountAdditionalData = {
/** Is a Peer-To-Peer Debit Card */
isP2PDebitCard?: boolean;

/** Owners that can benefit from this bank account */
beneficialOwners?: string[];

/** In which currency is the bank account */
currency?: string;

/** In which bank is the bank account */
bankName?: string;

/** Whether the bank account details were obtained for local transfer or international wire */
fieldsType?: string;

/** In which country is the bank account */
country?: string;
};

/** Model of bank account */
type BankAccount = OnyxCommon.OnyxValueWithOfflineFeedback<{
/** The bank account type */
accountType?: typeof CONST.PAYMENT_METHODS.PERSONAL_BANK_ACCOUNT;

/** string like 'Account ending in XXXX' */
description?: string;

/** Determines if the bank account is a default payment method */
isDefault?: boolean;

/* Determines if the bank account is a savings account */
isSavings?: boolean;

/** Date when the 3 micro amounts for validation were supposed to reach the bank account. */
/** Date when the 3 micro amounts for validation were supposed to reach the bank account */
validateCodeExpectedDate?: string;

/** string like 'bankAccount-{<bankAccountID>}' where <bankAccountID> is the bankAccountID */
/** string like `bankAccount-<bankAccountID>` */
key?: string;

/** Alias for bankAccountID */
Expand All @@ -42,7 +56,8 @@ type BankAccount = OnyxCommon.OnyxValueWithOfflineFeedback<{
errors?: OnyxCommon.Errors;
}>;

/** Record of bank accounts, indexed by bankAccountID */
type BankAccountList = Record<string, BankAccount>;

export default BankAccount;
export type {AccountData, AdditionalData, BankAccountList};
export type {AccountData, BankAccountAdditionalData, BankAccountList};
1 change: 1 addition & 0 deletions src/types/onyx/Beta.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type {ValueOf} from 'type-fest';
import type CONST from '@src/CONST';

/** New Dot Beta features */
type Beta = ValueOf<typeof CONST.BETAS>;

export default Beta;
1 change: 1 addition & 0 deletions src/types/onyx/BlockedFromConcierge.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/** Model of blocked user from concierge */
type BlockedFromConcierge = {
/** The date that the user will be unblocked */
expiresAt: string;
Expand Down
Loading
Loading