diff --git a/src/libs/PersonalDetailsUtils.ts b/src/libs/PersonalDetailsUtils.ts index c62b43114b432..a60a9ef0079b0 100644 --- a/src/libs/PersonalDetailsUtils.ts +++ b/src/libs/PersonalDetailsUtils.ts @@ -236,7 +236,7 @@ function getPersonalDetailsOnyxDataForOptimisticUsers( personalDetailsCleanup[accountID] = null; } - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.PERSONAL_DETAILS_LIST, @@ -244,7 +244,7 @@ function getPersonalDetailsOnyxDataForOptimisticUsers( }, ]; - const finallyData: OnyxUpdate[] = [ + const finallyData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.PERSONAL_DETAILS_LIST, diff --git a/src/libs/PolicyDistanceRatesUtils.ts b/src/libs/PolicyDistanceRatesUtils.ts index 1791e7f1da1b7..b4f43be51b9b3 100644 --- a/src/libs/PolicyDistanceRatesUtils.ts +++ b/src/libs/PolicyDistanceRatesUtils.ts @@ -87,7 +87,7 @@ function buildOnyxDataForPolicyDistanceRateUpdates(policyID: string, customUnit: } } - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -101,7 +101,7 @@ function buildOnyxDataForPolicyDistanceRateUpdates(policyID: string, customUnit: }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -115,7 +115,7 @@ function buildOnyxDataForPolicyDistanceRateUpdates(policyID: string, customUnit: }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, diff --git a/src/libs/ReportTitleUtils.ts b/src/libs/ReportTitleUtils.ts index 006e49049c933..fb7482d684a33 100644 --- a/src/libs/ReportTitleUtils.ts +++ b/src/libs/ReportTitleUtils.ts @@ -69,7 +69,7 @@ function updateTitleFieldToMatchPolicy(reportID: string, policy?: Policy): OnyxU } // Create the update to set/update the title field in rNVP - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${reportID}`, @@ -94,7 +94,7 @@ function removeTitleFieldFromReport(reportID: string): OnyxUpdate[] { return []; } - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${reportID}`, diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index ef94108d66e22..9c8181b476581 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -10361,9 +10361,11 @@ function getTaskAssigneeChatOnyxData( let optimisticChatCreatedReportAction: OptimisticCreatedReportAction | undefined; const assigneeChatReportMetadata = getReportMetadata(assigneeChatReportID); const currentTime = DateUtils.getDBTime(); - const optimisticData: OnyxUpdate[] = []; - const successData: OnyxUpdate[] = []; - const failureData: OnyxUpdate[] = []; + const optimisticData: Array> = []; + const successData: Array< + OnyxUpdate + > = []; + const failureData: Array> = []; // You're able to assign a task to someone you haven't chatted with before - so we need to optimistically create the chat and the chat reportActions // Only add the assignee chat report to onyx if we haven't already set it optimistically diff --git a/src/libs/actions/App.ts b/src/libs/actions/App.ts index 8c693b1df7c50..e0b6eefc12f73 100644 --- a/src/libs/actions/App.ts +++ b/src/libs/actions/App.ts @@ -181,7 +181,7 @@ function setLocale(locale: Locale, currentPreferredLocale: Locale | undefined) { } // Optimistically change preferred locale - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.NVP_PREFERRED_LOCALE, diff --git a/src/libs/actions/Card.ts b/src/libs/actions/Card.ts index c692f66b1dd54..50abba9e0a4f1 100644 --- a/src/libs/actions/Card.ts +++ b/src/libs/actions/Card.ts @@ -47,12 +47,12 @@ type IssueNewCardFlowData = { function reportVirtualExpensifyCardFraud(card: Card, validateCode: string) { const cardID = card?.cardID ?? CONST.DEFAULT_NUMBER_ID; - const optimisticData: OnyxUpdate[] = [ - // @ts-expect-error - will be solved in https://github.com/Expensify/App/issues/73830 + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.FORMS.REPORT_VIRTUAL_CARD_FRAUD, value: { + // @ts-expect-error - will be solved in https://github.com/Expensify/App/issues/73830 cardID, isLoading: true, errors: null, @@ -65,7 +65,7 @@ function reportVirtualExpensifyCardFraud(card: Card, validateCode: string) { }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.FORMS.REPORT_VIRTUAL_CARD_FRAUD, @@ -80,7 +80,7 @@ function reportVirtualExpensifyCardFraud(card: Card, validateCode: string) { }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.FORMS.REPORT_VIRTUAL_CARD_FRAUD, @@ -113,7 +113,7 @@ function reportVirtualExpensifyCardFraud(card: Card, validateCode: string) { * @param reason - reason for replacement */ function requestReplacementExpensifyCard(cardID: number, reason: ReplacementReason, validateCode: string) { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.FORMS.REPORT_PHYSICAL_CARD_FORM, @@ -131,7 +131,7 @@ function requestReplacementExpensifyCard(cardID: number, reason: ReplacementReas }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.FORMS.REPORT_PHYSICAL_CARD_FORM, @@ -141,7 +141,7 @@ function requestReplacementExpensifyCard(cardID: number, reason: ReplacementReas }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.FORMS.REPORT_PHYSICAL_CARD_FORM, @@ -168,7 +168,7 @@ function requestReplacementExpensifyCard(cardID: number, reason: ReplacementReas * Activates the physical Expensify card based on the last four digits of the card number */ function activatePhysicalExpensifyCard(cardLastFourDigits: string, cardID: number) { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.CARD_LIST, @@ -181,7 +181,7 @@ function activatePhysicalExpensifyCard(cardLastFourDigits: string, cardID: numbe }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.CARD_LIST, @@ -193,7 +193,7 @@ function activatePhysicalExpensifyCard(cardLastFourDigits: string, cardID: numbe }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.CARD_LIST, @@ -257,7 +257,7 @@ function revealVirtualCardDetails(cardID: number, validateCode: string): Promise return new Promise((resolve, reject) => { const parameters: RevealExpensifyCardDetailsParams = {cardID, validateCode}; - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.ACCOUNT, @@ -265,7 +265,7 @@ function revealVirtualCardDetails(cardID: number, validateCode: string): Promise }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.ACCOUNT, @@ -273,7 +273,7 @@ function revealVirtualCardDetails(cardID: number, validateCode: string): Promise }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.ACCOUNT, @@ -321,7 +321,7 @@ function revealVirtualCardDetails(cardID: number, validateCode: string): Promise function updateSettlementFrequency(workspaceAccountID: number, settlementFrequency: ValueOf, currentFrequency?: Date) { const monthlySettlementDate = settlementFrequency === CONST.EXPENSIFY_CARD.FREQUENCY_SETTING.DAILY ? null : new Date(); - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.PRIVATE_EXPENSIFY_CARD_SETTINGS}${workspaceAccountID}`, @@ -331,7 +331,7 @@ function updateSettlementFrequency(workspaceAccountID: number, settlementFrequen }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.PRIVATE_EXPENSIFY_CARD_SETTINGS}${workspaceAccountID}`, @@ -341,7 +341,7 @@ function updateSettlementFrequency(workspaceAccountID: number, settlementFrequen }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.PRIVATE_EXPENSIFY_CARD_SETTINGS}${workspaceAccountID}`, @@ -364,7 +364,7 @@ function updateSettlementAccount(domainName: string, workspaceAccountID: number, return; } - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.PRIVATE_EXPENSIFY_CARD_SETTINGS}${workspaceAccountID}`, @@ -375,7 +375,7 @@ function updateSettlementAccount(domainName: string, workspaceAccountID: number, }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.PRIVATE_EXPENSIFY_CARD_SETTINGS}${workspaceAccountID}`, @@ -386,7 +386,7 @@ function updateSettlementAccount(domainName: string, workspaceAccountID: number, }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.PRIVATE_EXPENSIFY_CARD_SETTINGS}${workspaceAccountID}`, @@ -459,7 +459,7 @@ function updateExpensifyCardLimit( return; } - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST}${workspaceAccountID}_${CONST.EXPENSIFY_CARD.BANK}`, @@ -479,7 +479,7 @@ function updateExpensifyCardLimit( }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST}${workspaceAccountID}_${CONST.EXPENSIFY_CARD.BANK}`, @@ -496,7 +496,7 @@ function updateExpensifyCardLimit( }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST}${workspaceAccountID}_${CONST.EXPENSIFY_CARD.BANK}`, @@ -533,7 +533,7 @@ function updateExpensifyCardTitle(workspaceAccountID: number, cardID: number, ne return; } - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST}${workspaceAccountID}_${CONST.EXPENSIFY_CARD.BANK}`, @@ -551,7 +551,7 @@ function updateExpensifyCardTitle(workspaceAccountID: number, cardID: number, ne }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST}${workspaceAccountID}_${CONST.EXPENSIFY_CARD.BANK}`, @@ -567,7 +567,7 @@ function updateExpensifyCardTitle(workspaceAccountID: number, cardID: number, ne }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST}${workspaceAccountID}_${CONST.EXPENSIFY_CARD.BANK}`, @@ -601,7 +601,7 @@ function updateExpensifyCardLimitType(workspaceAccountID: number, cardID: number return; } - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST}${workspaceAccountID}_${CONST.EXPENSIFY_CARD.BANK}`, @@ -620,7 +620,7 @@ function updateExpensifyCardLimitType(workspaceAccountID: number, cardID: number }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST}${workspaceAccountID}_${CONST.EXPENSIFY_CARD.BANK}`, @@ -637,7 +637,7 @@ function updateExpensifyCardLimitType(workspaceAccountID: number, cardID: number }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST}${workspaceAccountID}_${CONST.EXPENSIFY_CARD.BANK}`, @@ -673,7 +673,7 @@ function deactivateCard(workspaceAccountID: number, card?: Card) { return; } - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST}${workspaceAccountID}_${CONST.EXPENSIFY_CARD.BANK}`, @@ -690,7 +690,7 @@ function deactivateCard(workspaceAccountID: number, card?: Card) { }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST}${workspaceAccountID}_${CONST.EXPENSIFY_CARD.BANK}`, @@ -736,7 +736,7 @@ function configureExpensifyCardsForPolicy(policyID: string, bankAccountID?: numb const workspaceAccountID = PolicyUtils.getWorkspaceAccountID(policyID); - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.PRIVATE_EXPENSIFY_CARD_SETTINGS}${workspaceAccountID}`, @@ -754,7 +754,7 @@ function configureExpensifyCardsForPolicy(policyID: string, bankAccountID?: numb }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.PRIVATE_EXPENSIFY_CARD_SETTINGS}${workspaceAccountID}`, @@ -772,7 +772,7 @@ function configureExpensifyCardsForPolicy(policyID: string, bankAccountID?: numb }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.PRIVATE_EXPENSIFY_CARD_SETTINGS}${workspaceAccountID}`, @@ -810,7 +810,7 @@ function issueExpensifyCard(domainAccountID: number, policyID: string | undefine const {assigneeEmail, limit, limitType, cardTitle, cardType} = data; - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.ISSUE_NEW_EXPENSIFY_CARD}${policyID}`, @@ -822,7 +822,7 @@ function issueExpensifyCard(domainAccountID: number, policyID: string | undefine }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.ISSUE_NEW_EXPENSIFY_CARD}${policyID}`, @@ -833,7 +833,7 @@ function issueExpensifyCard(domainAccountID: number, policyID: string | undefine }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.ISSUE_NEW_EXPENSIFY_CARD}${policyID}`, @@ -905,7 +905,9 @@ function toggleContinuousReconciliation(workspaceAccountID: number, shouldUseCon shouldUseContinuousReconciliation, }; - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array< + OnyxUpdate + > = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.EXPENSIFY_CARD_USE_CONTINUOUS_RECONCILIATION}${workspaceAccountID}`, @@ -921,7 +923,9 @@ function toggleContinuousReconciliation(workspaceAccountID: number, shouldUseCon }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array< + OnyxUpdate + > = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.EXPENSIFY_CARD_USE_CONTINUOUS_RECONCILIATION}${workspaceAccountID}`, @@ -937,7 +941,9 @@ function toggleContinuousReconciliation(workspaceAccountID: number, shouldUseCon }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array< + OnyxUpdate + > = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.EXPENSIFY_CARD_USE_CONTINUOUS_RECONCILIATION}${workspaceAccountID}`, @@ -1009,7 +1015,7 @@ function resolveFraudAlert(cardID: number | undefined, isFraud: boolean, reportI const resolution = isFraud ? CONST.CARD_FRAUD_ALERT_RESOLUTION.FRAUD : CONST.CARD_FRAUD_ALERT_RESOLUTION.RECOGNIZED; - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`, @@ -1024,7 +1030,7 @@ function resolveFraudAlert(cardID: number | undefined, isFraud: boolean, reportI }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`, @@ -1036,7 +1042,7 @@ function resolveFraudAlert(cardID: number | undefined, isFraud: boolean, reportI }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`, diff --git a/src/libs/actions/Chronos.ts b/src/libs/actions/Chronos.ts index 5a54c2ee93687..1c26a1f79d177 100644 --- a/src/libs/actions/Chronos.ts +++ b/src/libs/actions/Chronos.ts @@ -8,7 +8,7 @@ import ONYXKEYS from '@src/ONYXKEYS'; import type {ChronosOOOEvent} from '@src/types/onyx/OriginalMessage'; const removeEvent = (reportID: string | undefined, reportActionID: string, eventID: string, events: ChronosOOOEvent[]) => { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`, @@ -23,7 +23,7 @@ const removeEvent = (reportID: string | undefined, reportActionID: string, event }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`, @@ -35,7 +35,7 @@ const removeEvent = (reportID: string | undefined, reportActionID: string, event }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`, diff --git a/src/libs/actions/CompanyCards.ts b/src/libs/actions/CompanyCards.ts index 898230b9ab191..ea0f4ab5b5100 100644 --- a/src/libs/actions/CompanyCards.ts +++ b/src/libs/actions/CompanyCards.ts @@ -90,7 +90,7 @@ function addNewCompanyCardsFeed( const feedType = CardUtils.getFeedType(cardFeed, cardFeeds); const newSelectedFeed = getCompanyCardFeedWithDomainID(feedType as CompanyCardFeed, workspaceAccountID); - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.LAST_SELECTED_FEED}${policyID}`, @@ -113,7 +113,7 @@ function addNewCompanyCardsFeed( }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.LAST_SELECTED_FEED}${policyID}`, @@ -133,7 +133,7 @@ function addNewCompanyCardsFeed( }, ]; - const finallyData: OnyxUpdate[] = [ + const finallyData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_DOMAIN_MEMBER}${workspaceAccountID}`, @@ -224,7 +224,14 @@ function deleteWorkspaceCompanyCardFeed(policyID: string, domainOrWorkspaceAccou const successCardUpdates = Object.fromEntries(cardIDs.map((cardID) => [cardID, null])); const failureCardUpdates = Object.fromEntries(cardIDs.map((cardID) => [cardID, {pendingAction: null}])); - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array< + OnyxUpdate< + | typeof ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_DOMAIN_MEMBER + | typeof ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST + | typeof ONYXKEYS.CARD_LIST + | typeof ONYXKEYS.COLLECTION.LAST_SELECTED_FEED + > + > = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_DOMAIN_MEMBER}${domainOrWorkspaceAccountID}`, @@ -246,7 +253,7 @@ function deleteWorkspaceCompanyCardFeed(policyID: string, domainOrWorkspaceAccou }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_DOMAIN_MEMBER}${domainOrWorkspaceAccountID}`, @@ -271,7 +278,7 @@ function deleteWorkspaceCompanyCardFeed(policyID: string, domainOrWorkspaceAccou }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_DOMAIN_MEMBER}${domainOrWorkspaceAccountID}`, @@ -485,7 +492,7 @@ function resetFailedWorkspaceCompanyCardAssignment(domainOrWorkspaceAccountID: n function updateWorkspaceCompanyCard(domainOrWorkspaceAccountID: number, cardID: string, bankName: CompanyCardFeed, lastScrapeResult?: number) { const authToken = NetworkStore.getAuthToken(); - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST}${domainOrWorkspaceAccountID}_${bankName}`, @@ -520,7 +527,7 @@ function updateWorkspaceCompanyCard(domainOrWorkspaceAccountID: number, cardID: }, ]; - const finallyData: OnyxUpdate[] = [ + const finallyData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST}${domainOrWorkspaceAccountID}_${bankName}`, @@ -549,7 +556,7 @@ function updateWorkspaceCompanyCard(domainOrWorkspaceAccountID: number, cardID: }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST}${domainOrWorkspaceAccountID}_${bankName}`, @@ -595,7 +602,7 @@ function updateWorkspaceCompanyCard(domainOrWorkspaceAccountID: number, cardID: function updateCompanyCardName(domainOrWorkspaceAccountID: number, cardID: string, newCardTitle: string, bankName: CompanyCardFeed, oldCardTitle?: string) { const authToken = NetworkStore.getAuthToken(); - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST}${domainOrWorkspaceAccountID}_${bankName}`, @@ -620,7 +627,7 @@ function updateCompanyCardName(domainOrWorkspaceAccountID: number, cardID: strin }, ]; - const finallyData: OnyxUpdate[] = [ + const finallyData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST}${domainOrWorkspaceAccountID}_${bankName}`, @@ -635,7 +642,7 @@ function updateCompanyCardName(domainOrWorkspaceAccountID: number, cardID: strin }, }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST}${domainOrWorkspaceAccountID}_${bankName}`, @@ -671,7 +678,7 @@ function updateCompanyCardName(domainOrWorkspaceAccountID: number, cardID: strin function setCompanyCardExportAccount(policyID: string, domainOrWorkspaceAccountID: number, cardID: string, accountKey: string, newAccount: string, bank: CompanyCardFeed) { const authToken = NetworkStore.getAuthToken(); - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST}${domainOrWorkspaceAccountID}_${bank}`, @@ -691,7 +698,7 @@ function setCompanyCardExportAccount(policyID: string, domainOrWorkspaceAccountI }, ]; - const finallyData: OnyxUpdate[] = [ + const finallyData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST}${domainOrWorkspaceAccountID}_${bank}`, @@ -706,7 +713,7 @@ function setCompanyCardExportAccount(policyID: string, domainOrWorkspaceAccountI }, }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST}${domainOrWorkspaceAccountID}_${bank}`, @@ -764,7 +771,7 @@ function clearCompanyCardErrorField(domainOrWorkspaceAccountID: number, cardID: function openPolicyCompanyCardsPage(policyID: string, domainOrWorkspaceAccountID: number) { const authToken = NetworkStore.getAuthToken(); - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_DOMAIN_MEMBER}${domainOrWorkspaceAccountID}`, @@ -774,7 +781,7 @@ function openPolicyCompanyCardsPage(policyID: string, domainOrWorkspaceAccountID }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_DOMAIN_MEMBER}${domainOrWorkspaceAccountID}`, @@ -784,7 +791,7 @@ function openPolicyCompanyCardsPage(policyID: string, domainOrWorkspaceAccountID }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_DOMAIN_MEMBER}${domainOrWorkspaceAccountID}`, @@ -818,7 +825,7 @@ function openAssignFeedCardPage(policyID: string, feed: CompanyCardFeed, domainO feed, }; - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_DOMAIN_MEMBER}${domainOrWorkspaceAccountID}`, @@ -828,7 +835,7 @@ function openAssignFeedCardPage(policyID: string, feed: CompanyCardFeed, domainO }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_DOMAIN_MEMBER}${domainOrWorkspaceAccountID}`, @@ -838,7 +845,7 @@ function openAssignFeedCardPage(policyID: string, feed: CompanyCardFeed, domainO }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_DOMAIN_MEMBER}${domainOrWorkspaceAccountID}`, @@ -873,7 +880,7 @@ function setFeedStatementPeriodEndDay( ) { const authToken = NetworkStore.getAuthToken(); - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_DOMAIN_MEMBER}${domainAccountID}`, @@ -895,7 +902,7 @@ function setFeedStatementPeriodEndDay( }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_DOMAIN_MEMBER}${domainAccountID}`, @@ -913,7 +920,7 @@ function setFeedStatementPeriodEndDay( }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_DOMAIN_MEMBER}${domainAccountID}`, diff --git a/src/libs/actions/Delegate.ts b/src/libs/actions/Delegate.ts index 563378dd04f2a..76bf304b06dd1 100644 --- a/src/libs/actions/Delegate.ts +++ b/src/libs/actions/Delegate.ts @@ -126,7 +126,7 @@ function connect({email, delegatedAccess, credentials, session, activePolicyID, const previousAccountID = getCurrentUserAccountID(); - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.ACCOUNT, @@ -142,7 +142,7 @@ function connect({email, delegatedAccess, credentials, session, activePolicyID, }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.ACCOUNT, @@ -158,7 +158,7 @@ function connect({email, delegatedAccess, credentials, session, activePolicyID, }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.ACCOUNT, @@ -222,7 +222,7 @@ function connect({email, delegatedAccess, credentials, session, activePolicyID, } function disconnect({stashedCredentials, stashedSession}: DisconnectParams) { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.ACCOUNT, @@ -234,7 +234,7 @@ function disconnect({stashedCredentials, stashedSession}: DisconnectParams) { }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.ACCOUNT, @@ -246,7 +246,7 @@ function disconnect({stashedCredentials, stashedSession}: DisconnectParams) { }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.ACCOUNT, @@ -413,7 +413,7 @@ function addDelegate({email, role, validateCode, delegatedAccess}: AddDelegatePa ]; }; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.ACCOUNT, @@ -457,7 +457,7 @@ function addDelegate({email, role, validateCode, delegatedAccess}: AddDelegatePa ]; }; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.ACCOUNT, @@ -489,7 +489,7 @@ function removeDelegate({email, delegatedAccess}: RemoveDelegateParams) { return; } - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.ACCOUNT, @@ -514,7 +514,7 @@ function removeDelegate({email, delegatedAccess}: RemoveDelegateParams) { }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.ACCOUNT, @@ -526,7 +526,7 @@ function removeDelegate({email, delegatedAccess}: RemoveDelegateParams) { }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.ACCOUNT, @@ -581,7 +581,7 @@ function updateDelegateRole({email, role, validateCode, delegatedAccess}: Update return; } - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.ACCOUNT, @@ -608,7 +608,7 @@ function updateDelegateRole({email, role, validateCode, delegatedAccess}: Update }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.ACCOUNT, @@ -636,7 +636,7 @@ function updateDelegateRole({email, role, validateCode, delegatedAccess}: Update }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.ACCOUNT, @@ -668,7 +668,7 @@ function clearDelegateRolePendingAction({email, delegatedAccess}: ClearDelegateR return; } - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.ACCOUNT, diff --git a/src/libs/actions/Domain.ts b/src/libs/actions/Domain.ts index 51d553f1d841d..fa434a394ca46 100644 --- a/src/libs/actions/Domain.ts +++ b/src/libs/actions/Domain.ts @@ -14,14 +14,14 @@ import {ScimTokenState} from './ScimToken/ScimTokenUtils'; * Fetches a validation code that the user is supposed to put in the domain's DNS records to verify it */ function getDomainValidationCode(accountID: number, domainName: string) { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.DOMAIN}${accountID}`, value: {isValidateCodeLoading: true, validateCodeError: null}, }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.DOMAIN}${accountID}`, @@ -29,7 +29,7 @@ function getDomainValidationCode(accountID: number, domainName: string) { }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.DOMAIN}${accountID}`, @@ -47,7 +47,7 @@ function getDomainValidationCode(accountID: number, domainName: string) { * Checks if the validation code is present in the domain's DNS records to mark the domain as validated and the user as a verified admin */ function validateDomain(accountID: number, domainName: string) { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.DOMAIN}${accountID}`, @@ -55,7 +55,7 @@ function validateDomain(accountID: number, domainName: string) { }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.DOMAIN}${accountID}`, @@ -63,7 +63,7 @@ function validateDomain(accountID: number, domainName: string) { }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.DOMAIN}${accountID}`, @@ -97,7 +97,7 @@ function openDomainInitialPage(domainName: string) { * Sets SAML identity provider metadata for a domain */ function setSamlIdentity(accountID: number, domainName: string, metaIdentity: string) { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.SAML_METADATA}${accountID}`, @@ -114,7 +114,7 @@ function setSamlIdentity(accountID: number, domainName: string, metaIdentity: st }, }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.SAML_METADATA}${accountID}`, @@ -131,7 +131,7 @@ function setSamlIdentity(accountID: number, domainName: string, metaIdentity: st * Fetches the domain's SAML metadata */ function getSamlSettings(accountID: number, domainName: string) { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.SAML_METADATA}${accountID}`, @@ -142,7 +142,7 @@ function getSamlSettings(accountID: number, domainName: string) { }, }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.SAML_METADATA}${accountID}`, @@ -151,7 +151,7 @@ function getSamlSettings(accountID: number, domainName: string) { }, }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.SAML_METADATA}${accountID}`, @@ -169,7 +169,7 @@ function getSamlSettings(accountID: number, domainName: string) { * Sets whether logging in via SAML is enabled for the domain */ function setSamlEnabled({enabled, accountID, domainName}: {enabled: boolean; accountID: number; domainName: string}) { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_DOMAIN_MEMBER}${accountID}`, @@ -188,14 +188,14 @@ function setSamlEnabled({enabled, accountID, domainName}: {enabled: boolean; acc }, }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.DOMAIN}${accountID}`, value: {isSamlEnabledLoading: null}, }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.DOMAIN}${accountID}`, @@ -235,7 +235,7 @@ function setSamlRequired({required, accountID, domainName, metaIdentity}: {requi return; } - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_DOMAIN_MEMBER}${accountID}`, @@ -254,14 +254,14 @@ function setSamlRequired({required, accountID, domainName, metaIdentity}: {requi }, }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.DOMAIN}${accountID}`, value: {isSamlRequiredLoading: null}, }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.DOMAIN}${accountID}`, @@ -320,14 +320,14 @@ async function getScimToken(domainName: string): Promise { /** Sends request for claiming a domain */ function createDomain(domainName: string) { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.FORMS.CREATE_DOMAIN_FORM, value: {hasCreationSucceeded: null, isLoading: true}, }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.FORMS.CREATE_DOMAIN_FORM, @@ -354,7 +354,7 @@ function resetCreateDomainForm() { } function setPrimaryContact(domainAccountID: number, newTechnicalContactAccountID: number, newTechnicalContactEmail: string, currentTechnicalContactEmail?: string) { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_DOMAIN_MEMBER}${domainAccountID}`, @@ -372,7 +372,7 @@ function setPrimaryContact(domainAccountID: number, newTechnicalContactAccountID }, }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.DOMAIN_PENDING_ACTIONS}${domainAccountID}`, @@ -381,7 +381,7 @@ function setPrimaryContact(domainAccountID: number, newTechnicalContactAccountID }, }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_DOMAIN_MEMBER}${domainAccountID}`, diff --git a/src/libs/actions/ExitSurvey.ts b/src/libs/actions/ExitSurvey.ts index b2c14c33681ff..dfcb0f3ed7fa0 100644 --- a/src/libs/actions/ExitSurvey.ts +++ b/src/libs/actions/ExitSurvey.ts @@ -13,7 +13,7 @@ function saveResponse(response: string) { * Save the user's response to the mandatory exit survey in the back-end. */ function switchToOldDot(exitSurveyResponse: string | undefined) { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.SET, key: ONYXKEYS.FORMS.EXIT_SURVEY_RESPONSE_FORM, diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index b36d09212182e..422678fc4026b 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -1555,7 +1555,7 @@ type BuildOnyxDataForTestDriveIOUParams = { }; function buildOnyxDataForTestDriveIOU(testDriveIOUParams: BuildOnyxDataForTestDriveIOUParams): OnyxData { - const optimisticData: OnyxUpdate[] = []; + const optimisticData: Array> = []; const successData: OnyxUpdate[] = []; const failureData: OnyxUpdate[] = []; @@ -2538,7 +2538,9 @@ function buildOnyxDataForInvoice(invoiceParams: BuildOnyxDataForInvoiceParams): const errorKey = DateUtils.getMicroseconds(); - const failureData: OnyxUpdate[] = [ + const failureData: Array< + OnyxUpdate + > = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${chat.report?.reportID}`, @@ -3170,7 +3172,9 @@ function getDeleteTrackExpenseInformation( const {lastMessageText = '', lastMessageHtml = ''} = getLastVisibleMessage(chatReportID, canUserPerformWriteAction, updatedReportAction); // STEP 4: Build Onyx data - const optimisticData: OnyxUpdate[] = []; + const optimisticData: Array< + OnyxUpdate + > = []; if (shouldDeleteTransactionFromOnyx && shouldRemoveIOUTransaction) { optimisticData.push({ @@ -3238,7 +3242,7 @@ function getDeleteTrackExpenseInformation( }, ); - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${chatReport?.reportID}`, @@ -3261,7 +3265,9 @@ function getDeleteTrackExpenseInformation( }); } - const failureData: OnyxUpdate[] = []; + const failureData: Array< + OnyxUpdate + > = []; if (shouldDeleteTransactionFromOnyx && shouldRemoveIOUTransaction) { failureData.push({ @@ -4498,8 +4504,19 @@ function getUpdateMoneyRequestParams(params: GetUpdateMoneyRequestParamsType): U isASAPSubmitBetaEnabled, } = params; const optimisticData: OnyxUpdate[] = []; - const successData: OnyxUpdate[] = []; - const failureData: OnyxUpdate[] = []; + const successData: Array< + OnyxUpdate + > = []; + const failureData: Array< + OnyxUpdate< + | typeof ONYXKEYS.COLLECTION.TRANSACTION + | typeof ONYXKEYS.COLLECTION.REPORT + | typeof ONYXKEYS.COLLECTION.REPORT_ACTIONS + | typeof ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS + | typeof ONYXKEYS.COLLECTION.SNAPSHOT + | typeof ONYXKEYS.COLLECTION.NEXT_STEP + > + > = []; // Step 1: Set any "pending fields" (ones updated while the user was offline) to have error messages in the failureData const pendingFields: OnyxTypes.Transaction['pendingFields'] = Object.fromEntries(Object.keys(transactionChanges).map((key) => [key, CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE])); @@ -5025,9 +5042,9 @@ function getUpdateTrackExpenseParams( policy: OnyxEntry, shouldBuildOptimisticModifiedExpenseReportAction = true, ): UpdateMoneyRequestData { - const optimisticData: OnyxUpdate[] = []; - const successData: OnyxUpdate[] = []; - const failureData: OnyxUpdate[] = []; + const optimisticData: Array> = []; + const successData: Array> = []; + const failureData: Array> = []; // Step 1: Set any "pending fields" (ones updated while the user was offline) to have error messages in the failureData const pendingFields = Object.fromEntries(Object.keys(transactionChanges).map((key) => [key, CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE])); @@ -7996,7 +8013,9 @@ function startSplitBill({ }); } - const successData: OnyxUpdate[] = [ + const successData: Array< + OnyxUpdate + > = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${splitChatReport.reportID}`, @@ -8031,7 +8050,9 @@ function startSplitBill({ }); } - const failureData: OnyxUpdate[] = [ + const failureData: Array< + OnyxUpdate + > = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.TRANSACTION}${splitTransaction.transactionID}`, @@ -9105,8 +9126,10 @@ function cleanUpMoneyRequest( // build Onyx data // Onyx operations to delete the transaction, update the IOU report action and chat report action - const reportActionsOnyxUpdates: OnyxUpdate[] = []; - const onyxUpdates: OnyxUpdate[] = [ + const reportActionsOnyxUpdates: Array> = []; + const onyxUpdates: Array< + OnyxUpdate + > = [ { onyxMethod: Onyx.METHOD.SET, key: `${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`, @@ -9311,7 +9334,15 @@ function deleteMoneyRequest({ // STEP 2: Build Onyx data // The logic mostly resembles the cleanUpMoneyRequest function - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array< + OnyxUpdate< + | typeof ONYXKEYS.COLLECTION.TRANSACTION + | typeof ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS + | typeof ONYXKEYS.COLLECTION.REPORT + | typeof ONYXKEYS.COLLECTION.REPORT_ACTIONS + | typeof ONYXKEYS.COLLECTION.SNAPSHOT + > + > = [ { onyxMethod: Onyx.METHOD.SET, key: `${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`, @@ -9833,7 +9864,7 @@ function getSendMoneyParams({ } : undefined; - const optimisticMetaData: OnyxUpdate[] = [ + const optimisticMetaData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_METADATA}${chatReport.reportID}`, @@ -9850,7 +9881,15 @@ function getSendMoneyParams({ }, ]; - const successData: OnyxUpdate[] = []; + const successData: Array< + OnyxUpdate< + | typeof ONYXKEYS.PERSONAL_DETAILS_LIST + | typeof ONYXKEYS.COLLECTION.REPORT + | typeof ONYXKEYS.COLLECTION.REPORT_METADATA + | typeof ONYXKEYS.COLLECTION.REPORT_ACTIONS + | typeof ONYXKEYS.COLLECTION.TRANSACTION + > + > = []; // Add optimistic personal details for recipient let optimisticPersonalDetailListData: OnyxUpdate | null = null; @@ -9949,7 +9988,9 @@ function getSendMoneyParams({ }, ); - const failureData: OnyxUpdate[] = [ + const failureData: Array< + OnyxUpdate + > = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.TRANSACTION}${optimisticTransaction.transactionID}`, @@ -10032,7 +10073,6 @@ function getSendMoneyParams({ }); } - // @ts-expect-error - will be solved in https://github.com/Expensify/App/issues/73830 // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment const optimisticData: OnyxUpdate[] = [ optimisticChatReportData, @@ -10199,7 +10239,7 @@ function getReportFromHoldRequestsOnyxData( }; } - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${chatReport.reportID}`, @@ -10262,7 +10302,7 @@ function getReportFromHoldRequestsOnyxData( bringHeldTransactionsBack[`${ONYXKEYS.COLLECTION.TRANSACTION}${transaction.transactionID}`] = transaction; } - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${chatReport.reportID}`, @@ -10279,7 +10319,7 @@ function getReportFromHoldRequestsOnyxData( }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${chatReport.reportID}`, @@ -11228,7 +11268,7 @@ function reopenReport( const optimisticData: OnyxUpdate[] = [optimisticIOUReportData, optimisticReportActionsData, optimisticNextStepData]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${expenseReport.reportID}`, @@ -11250,7 +11290,7 @@ function reopenReport( }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${expenseReport.reportID}`, @@ -11564,7 +11604,7 @@ function unapproveExpenseReport( const optimisticData: OnyxUpdate[] = [optimisticIOUReportData, optimisticReportActionData, optimisticNextStepData]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${expenseReport.reportID}`, @@ -11586,7 +11626,7 @@ function unapproveExpenseReport( }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${expenseReport.reportID}`, @@ -11763,7 +11803,7 @@ function submitReport( }); } - const successData: OnyxUpdate[] = []; + const successData: Array> = []; successData.push({ onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${expenseReport.reportID}`, @@ -11783,7 +11823,7 @@ function submitReport( }, }); - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${expenseReport.reportID}`, @@ -11879,7 +11919,7 @@ function cancelPayment( const expenseReportActions = getAllReportActions(expenseReport.reportID); const iouCreatedAction = Object.values(iouReportActions).find((action) => isCreatedAction(action)); const expenseCreatedAction = Object.values(expenseReportActions).find((action) => isCreatedAction(action)); - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${expenseReport.reportID}`, @@ -11924,7 +11964,7 @@ function cancelPayment( value: optimisticNextStepDeprecated, }); - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${expenseReport.reportID}`, @@ -11945,7 +11985,7 @@ function cancelPayment( }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${expenseReport.reportID}`, @@ -12228,7 +12268,7 @@ function detachReceipt(transactionID: string | undefined, transactionPolicy: Ony }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`, @@ -12239,7 +12279,9 @@ function detachReceipt(transactionID: string | undefined, transactionPolicy: Ony }, }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array< + OnyxUpdate + > = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`, @@ -12352,7 +12394,7 @@ function replaceReceipt({transactionID, file, source, transactionPolicy, transac }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`, @@ -12364,7 +12406,7 @@ function replaceReceipt({transactionID, file, source, transactionPolicy, transac }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`, @@ -12411,10 +12453,10 @@ function replaceReceipt({transactionID, file, source, transactionPolicy, transac }, }); - // @ts-expect-error - will be solved in https://github.com/Expensify/App/issues/73830 failureData.push({ onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.SNAPSHOT}${currentSearchQueryJSON.hash}`, + // @ts-expect-error - will be solved in https://github.com/Expensify/App/issues/73830 value: { data: { [`${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`]: { @@ -12671,7 +12713,7 @@ function putOnHold(transactionID: string, comment: string, initialReportID: stri optimisticData.push(parentActionData); } - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`, @@ -12681,7 +12723,9 @@ function putOnHold(transactionID: string, comment: string, initialReportID: stri }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array< + OnyxUpdate + > = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`, @@ -12819,7 +12863,9 @@ function unholdRequest(transactionID: string, reportID: string) { const iouReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${transaction?.reportID}`]; const report = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${reportID}`]; - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array< + OnyxUpdate + > = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`, @@ -12840,7 +12886,6 @@ function unholdRequest(transactionID: string, reportID: string) { { onyxMethod: Onyx.METHOD.SET, key: `${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${transactionID}`, - // @ts-expect-error - will be solved in https://github.com/Expensify/App/issues/73830 value: transactionViolations?.filter((violation) => violation.name !== CONST.VIOLATIONS.HOLD) ?? [], }, { @@ -12866,7 +12911,7 @@ function unholdRequest(transactionID: string, reportID: string) { }); } - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`, @@ -12879,7 +12924,9 @@ function unholdRequest(transactionID: string, reportID: string) { }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array< + OnyxUpdate + > = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`, @@ -13170,7 +13217,7 @@ function mergeDuplicates({transactionThreadReportID: optimisticTransactionThread const optimisticData: OnyxUpdate[] = []; const failureData: OnyxUpdate[] = []; - const successData: OnyxUpdate[] = []; + const successData: Array> = []; optimisticData.push( optimisticTransactionData, @@ -13335,11 +13382,11 @@ function resolveDuplicates(params: MergeDuplicatesParams) { }) .filter((id): id is string => !!id); - const optimisticHoldActions: OnyxUpdate[] = []; - const failureHoldActions: OnyxUpdate[] = []; + const optimisticHoldActions: Array> = []; + const failureHoldActions: Array> = []; const reportActionIDList: string[] = []; - const optimisticHoldTransactionActions: OnyxUpdate[] = []; - const failureHoldTransactionActions: OnyxUpdate[] = []; + const optimisticHoldTransactionActions: Array> = []; + const failureHoldTransactionActions: Array> = []; for (const action of iouActionList) { const transactionThreadReportID = action?.childReportID; const createdReportAction = buildOptimisticHoldReportAction(); @@ -13583,7 +13630,7 @@ function dismissRejectUseExplanation() { value: true, }; - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.NVP_DISMISSED_REJECT_USE_EXPLANATION, @@ -13658,7 +13705,16 @@ function prepareRejectMoneyRequestData( })(); // Build optimistic data updates - const optimisticData: OnyxUpdate[] = []; + const optimisticData: Array< + OnyxUpdate< + | typeof ONYXKEYS.COLLECTION.REPORT + | typeof ONYXKEYS.COLLECTION.TRANSACTION + | typeof ONYXKEYS.COLLECTION.REPORT_ACTIONS + | typeof ONYXKEYS.COLLECTION.REPORT_METADATA + | typeof ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS + | typeof ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS + > + > = []; // Create system messages in both expense report and expense thread // The "rejected this expense" action should come before the reject comment @@ -13668,8 +13724,19 @@ function prepareRejectMoneyRequestData( let movedTransactionAction; // Build successData and failureData to prevent duplication - const successData: OnyxUpdate[] = []; - const failureData: OnyxUpdate[] = []; + const successData: Array< + OnyxUpdate + > = []; + const failureData: Array< + OnyxUpdate< + | typeof ONYXKEYS.COLLECTION.REPORT + | typeof ONYXKEYS.COLLECTION.TRANSACTION + | typeof ONYXKEYS.COLLECTION.REPORT_ACTIONS + | typeof ONYXKEYS.COLLECTION.REPORT_METADATA + | typeof ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS + | typeof ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS + > + > = []; if ((!isPolicyDelayedSubmissionEnabled || isIOU) && !shouldUseBulkAction) { if (hasMultipleExpenses) { @@ -14356,7 +14423,7 @@ function markRejectViolationAsResolved(transactionID: string, reportID?: string) const optimisticMarkedAsResolvedReportAction = buildOptimisticMarkedAsResolvedReportAction(); // Build optimistic data - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ // @ts-expect-error - will be solved in https://github.com/Expensify/App/issues/73830 { onyxMethod: Onyx.METHOD.MERGE, @@ -14372,7 +14439,7 @@ function markRejectViolationAsResolved(transactionID: string, reportID?: string) }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`, @@ -14384,7 +14451,7 @@ function markRejectViolationAsResolved(transactionID: string, reportID?: string) }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ // @ts-expect-error - will be solved in https://github.com/Expensify/App/issues/73830 { onyxMethod: Onyx.METHOD.MERGE, diff --git a/src/libs/actions/MergeAccounts.ts b/src/libs/actions/MergeAccounts.ts index f7a7ca58bb8ed..7222623262d6e 100644 --- a/src/libs/actions/MergeAccounts.ts +++ b/src/libs/actions/MergeAccounts.ts @@ -13,7 +13,7 @@ function requestValidationCodeForAccountMerge(email: string, validateCodeResent const parsedPhoneNumber = parsePhoneNumber(appendCountryCode(Str.removeSMSDomain(email), countryCode)); const normalizedEmail = parsedPhoneNumber.possible && parsedPhoneNumber.number?.e164 ? parsedPhoneNumber.number.e164 : email.toLowerCase(); - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.ACCOUNT, @@ -28,7 +28,7 @@ function requestValidationCodeForAccountMerge(email: string, validateCodeResent }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.ACCOUNT, @@ -43,7 +43,7 @@ function requestValidationCodeForAccountMerge(email: string, validateCodeResent }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.ACCOUNT, @@ -76,7 +76,7 @@ function clearGetValidateCodeForAccountMerge() { } function mergeWithValidateCode(email: string, validateCode: string) { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.ACCOUNT, @@ -90,7 +90,7 @@ function mergeWithValidateCode(email: string, validateCode: string) { }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.ACCOUNT, @@ -104,7 +104,7 @@ function mergeWithValidateCode(email: string, validateCode: string) { }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.ACCOUNT, diff --git a/src/libs/actions/PaymentMethods.ts b/src/libs/actions/PaymentMethods.ts index 9045fbe9b890f..c0055ae915731 100644 --- a/src/libs/actions/PaymentMethods.ts +++ b/src/libs/actions/PaymentMethods.ts @@ -43,21 +43,21 @@ function continueSetup(kycWallRef: RefObject, fallbackRoute?: } function getPaymentMethods(includePartiallySetupBankAccounts?: boolean) { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.IS_LOADING_PAYMENT_METHODS, value: true, }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.IS_LOADING_PAYMENT_METHODS, value: false, }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.IS_LOADING_PAYMENT_METHODS, @@ -169,7 +169,7 @@ function addPaymentCard(accountID: number, params: PaymentCardParams) { isP2PDebitCard: true, }; - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.FORMS.ADD_PAYMENT_CARD_FORM, @@ -177,7 +177,7 @@ function addPaymentCard(accountID: number, params: PaymentCardParams) { }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.FORMS.ADD_PAYMENT_CARD_FORM, @@ -185,7 +185,7 @@ function addPaymentCard(accountID: number, params: PaymentCardParams) { }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.FORMS.ADD_PAYMENT_CARD_FORM, @@ -233,7 +233,7 @@ function addSubscriptionPaymentCard( shouldClaimEarlyDiscountOffer: true, }; - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.FORMS.ADD_PAYMENT_CARD_FORM, @@ -241,7 +241,7 @@ function addSubscriptionPaymentCard( }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.FORMS.ADD_PAYMENT_CARD_FORM, @@ -249,7 +249,7 @@ function addSubscriptionPaymentCard( }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.FORMS.ADD_PAYMENT_CARD_FORM, @@ -340,7 +340,7 @@ function transferWalletBalance(paymentMethod: PaymentMethod) { [paymentMethodIDKey]: paymentMethod.methodID, }; - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: 'merge', key: ONYXKEYS.WALLET_TRANSFER, @@ -351,7 +351,7 @@ function transferWalletBalance(paymentMethod: PaymentMethod) { }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: 'merge', key: ONYXKEYS.WALLET_TRANSFER, @@ -363,7 +363,7 @@ function transferWalletBalance(paymentMethod: PaymentMethod) { }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: 'merge', key: ONYXKEYS.WALLET_TRANSFER, @@ -468,7 +468,7 @@ function deletePaymentCard(fundID: number) { fundID, }; - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.FUND_LIST}`, @@ -491,7 +491,7 @@ function updateBillingCurrency(currency: ValueOf> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.FORMS.CHANGE_BILLING_CURRENCY_FORM, @@ -502,7 +502,7 @@ function updateBillingCurrency(currency: ValueOf> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.FORMS.CHANGE_BILLING_CURRENCY_FORM, @@ -512,7 +512,7 @@ function updateBillingCurrency(currency: ValueOf> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.FORMS.CHANGE_BILLING_CURRENCY_FORM, @@ -539,7 +539,7 @@ function setInvoicingTransferBankAccount(bankAccountID: number, policyID: string policyID, }; - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -553,7 +553,7 @@ function setInvoicingTransferBankAccount(bankAccountID: number, policyID: string }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, diff --git a/src/libs/actions/PersonalDetails.ts b/src/libs/actions/PersonalDetails.ts index ebbae4b5a9244..eea7c4160fec7 100644 --- a/src/libs/actions/PersonalDetails.ts +++ b/src/libs/actions/PersonalDetails.ts @@ -115,7 +115,7 @@ function updateLegalName( currentUserPersonalDetail: Pick, ) { const parameters: UpdateLegalNameParams = {legalFirstName, legalLastName}; - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.PRIVATE_PERSONAL_DETAILS, @@ -316,7 +316,7 @@ function updateSelectedTimezone(selectedTimezone: SelectedTimezone, currentUserA * but the profile page will use other info (e.g. contact methods and pronouns) if they are already available in Onyx */ function openPublicProfilePage(accountID: number) { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.PERSONAL_DETAILS_METADATA, @@ -328,7 +328,7 @@ function openPublicProfilePage(accountID: number) { }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.PERSONAL_DETAILS_METADATA, @@ -340,7 +340,7 @@ function openPublicProfilePage(accountID: number) { }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.PERSONAL_DETAILS_METADATA, @@ -377,7 +377,7 @@ function updateAvatar( return; } - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.PERSONAL_DETAILS_LIST, @@ -398,7 +398,7 @@ function updateAvatar( }, }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.PERSONAL_DETAILS_LIST, @@ -411,7 +411,7 @@ function updateAvatar( }, }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.PERSONAL_DETAILS_LIST, @@ -444,7 +444,7 @@ function deleteAvatar(currentUserPersonalDetails: Pick> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.PERSONAL_DETAILS_LIST, @@ -456,7 +456,7 @@ function deleteAvatar(currentUserPersonalDetails: Pick> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.PERSONAL_DETAILS_LIST, @@ -560,7 +560,7 @@ function setPersonalDetailsAndRevealExpensifyCard( cardID, }; - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.PRIVATE_PERSONAL_DETAILS, @@ -575,7 +575,7 @@ function setPersonalDetailsAndRevealExpensifyCard( }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.PRIVATE_PERSONAL_DETAILS, @@ -595,7 +595,7 @@ function setPersonalDetailsAndRevealExpensifyCard( }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.PRIVATE_PERSONAL_DETAILS, diff --git a/src/libs/actions/Policy/Category.ts b/src/libs/actions/Policy/Category.ts index 1569e39d1b42d..a404d2854d4a6 100644 --- a/src/libs/actions/Policy/Category.ts +++ b/src/libs/actions/Policy/Category.ts @@ -1182,7 +1182,7 @@ function enablePolicyCategories(policyData: PolicyData, enabled: boolean, should } function setPolicyCustomUnitDefaultCategory(policyID: string, customUnitID: string, oldCategory: string | undefined, category: string) { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -1197,7 +1197,7 @@ function setPolicyCustomUnitDefaultCategory(policyID: string, customUnitID: stri }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -1211,7 +1211,7 @@ function setPolicyCustomUnitDefaultCategory(policyID: string, customUnitID: stri }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, diff --git a/src/libs/actions/Policy/DistanceRate.ts b/src/libs/actions/Policy/DistanceRate.ts index 11a705e20f2ba..b95b6e3cb3036 100644 --- a/src/libs/actions/Policy/DistanceRate.ts +++ b/src/libs/actions/Policy/DistanceRate.ts @@ -127,7 +127,7 @@ function enablePolicyDistanceRates(policyID: string, enabled: boolean, customUni } function createPolicyDistanceRate(policyID: string, customUnitID: string, customUnitRate: Rate) { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -146,7 +146,7 @@ function createPolicyDistanceRate(policyID: string, customUnitID: string, custom }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -164,7 +164,7 @@ function createPolicyDistanceRate(policyID: string, customUnitID: string, custom }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -242,7 +242,7 @@ function clearPolicyDistanceRateErrorFields(policyID: string, customUnitID: stri } function setPolicyDistanceRatesUnit(policyID: string, currentCustomUnit: CustomUnit, newCustomUnit: CustomUnit) { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -257,7 +257,7 @@ function setPolicyDistanceRatesUnit(policyID: string, currentCustomUnit: CustomU }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -271,7 +271,7 @@ function setPolicyDistanceRatesUnit(policyID: string, currentCustomUnit: CustomU }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -339,7 +339,7 @@ function setPolicyDistanceRatesEnabled(policyID: string, customUnit: CustomUnit, } } - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -353,7 +353,7 @@ function setPolicyDistanceRatesEnabled(policyID: string, customUnit: CustomUnit, }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -367,7 +367,7 @@ function setPolicyDistanceRatesEnabled(policyID: string, customUnit: CustomUnit, }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -441,8 +441,8 @@ function deletePolicyDistanceRates( }, ]; - const optimisticTransactionsViolations: OnyxUpdate[] = []; - const failureTransactionsViolations: OnyxUpdate[] = []; + const optimisticTransactionsViolations: Array> = []; + const failureTransactionsViolations: Array> = []; for (const transactionID of transactionIDsAffected) { const currentTransactionViolations = transactionViolations?.[`${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${transactionID}`] ?? []; diff --git a/src/libs/actions/Policy/Member.ts b/src/libs/actions/Policy/Member.ts index 00d282ceb4fa9..4e5b3149dd1c6 100644 --- a/src/libs/actions/Policy/Member.ts +++ b/src/libs/actions/Policy/Member.ts @@ -778,7 +778,7 @@ function requestWorkspaceOwnerChange(policyID: string | undefined, currentUserAc }); } - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -791,7 +791,7 @@ function requestWorkspaceOwnerChange(policyID: string | undefined, currentUserAc }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -805,7 +805,7 @@ function requestWorkspaceOwnerChange(policyID: string | undefined, currentUserAc }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -1160,7 +1160,7 @@ function acceptJoinRequest(reportID: string | undefined, reportAction: OnyxEntry } const choice = CONST.REPORT.ACTIONABLE_MENTION_JOIN_WORKSPACE_RESOLUTION.ACCEPT; - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`, @@ -1173,7 +1173,7 @@ function acceptJoinRequest(reportID: string | undefined, reportAction: OnyxEntry }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`, @@ -1186,7 +1186,7 @@ function acceptJoinRequest(reportID: string | undefined, reportAction: OnyxEntry }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`, @@ -1222,7 +1222,7 @@ function declineJoinRequest(reportID: string | undefined, reportAction: OnyxEntr return; } const choice = CONST.REPORT.ACTIONABLE_MENTION_JOIN_WORKSPACE_RESOLUTION.DECLINE; - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`, @@ -1235,7 +1235,7 @@ function declineJoinRequest(reportID: string | undefined, reportAction: OnyxEntr }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`, @@ -1248,7 +1248,7 @@ function declineJoinRequest(reportID: string | undefined, reportAction: OnyxEntr }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`, diff --git a/src/libs/actions/Policy/Plan.ts b/src/libs/actions/Policy/Plan.ts index a30e8bb677040..c5f8c922d0288 100644 --- a/src/libs/actions/Policy/Plan.ts +++ b/src/libs/actions/Policy/Plan.ts @@ -12,7 +12,7 @@ function OpenWorkspacePlanPage(policyID: string) { return; } - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -22,7 +22,7 @@ function OpenWorkspacePlanPage(policyID: string) { }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -32,7 +32,7 @@ function OpenWorkspacePlanPage(policyID: string) { }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, diff --git a/src/libs/actions/Policy/Policy.ts b/src/libs/actions/Policy/Policy.ts index 4f053035f3c0e..79fb3750128a2 100644 --- a/src/libs/actions/Policy/Policy.ts +++ b/src/libs/actions/Policy/Policy.ts @@ -641,7 +641,7 @@ function deleteWorkspace(params: DeleteWorkspaceActionParams) { function setWorkspaceAutoHarvesting(policy: Policy, enabled: boolean) { const policyID = policy.id; - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -658,7 +658,7 @@ function setWorkspaceAutoHarvesting(policy: Policy, enabled: boolean) { }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -675,7 +675,7 @@ function setWorkspaceAutoHarvesting(policy: Policy, enabled: boolean) { }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -698,7 +698,7 @@ function setWorkspaceAutoReportingFrequency(policyID: string, frequency: ValueOf const wasPolicyOnManualReporting = PolicyUtils.getCorrectedAutoReportingFrequency(policy) === CONST.POLICY.AUTO_REPORTING_FREQUENCIES.MANUAL; - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -726,7 +726,7 @@ function setWorkspaceAutoReportingFrequency(policyID: string, frequency: ValueOf }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -739,7 +739,7 @@ function setWorkspaceAutoReportingFrequency(policyID: string, frequency: ValueOf }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -762,7 +762,7 @@ function setWorkspaceAutoReportingMonthlyOffset(policyID: string | undefined, au // eslint-disable-next-line @typescript-eslint/no-deprecated const policy = getPolicy(policyID); - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -773,7 +773,7 @@ function setWorkspaceAutoReportingMonthlyOffset(policyID: string | undefined, au }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -785,7 +785,7 @@ function setWorkspaceAutoReportingMonthlyOffset(policyID: string | undefined, au }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -809,7 +809,7 @@ function setWorkspaceApprovalMode(policyID: string, approver: string, approvalMo approvalMode, }; - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -820,7 +820,7 @@ function setWorkspaceApprovalMode(policyID: string, approver: string, approvalMo }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -834,7 +834,7 @@ function setWorkspaceApprovalMode(policyID: string, approver: string, approvalMo }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -860,7 +860,7 @@ function setWorkspacePayer(policyID: string, reimburserEmail: string) { // eslint-disable-next-line @typescript-eslint/no-deprecated const policy = getPolicy(policyID); - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -873,7 +873,7 @@ function setWorkspacePayer(policyID: string, reimburserEmail: string) { }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -884,7 +884,7 @@ function setWorkspacePayer(policyID: string, reimburserEmail: string) { }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -979,7 +979,7 @@ function setWorkspaceReimbursement({policyID, reimbursementChoice, bankAccountID const policy = getPolicy(policyID); const lastUsedPaymentMethod = typeof lastPaymentMethod === 'string' ? lastPaymentMethod : lastPaymentMethod?.expense?.name; - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -994,7 +994,7 @@ function setWorkspaceReimbursement({policyID, reimbursementChoice, bankAccountID }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -1026,7 +1026,7 @@ function setWorkspaceReimbursement({policyID, reimbursementChoice, bankAccountID }); } - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -1052,7 +1052,9 @@ function leaveWorkspace(policyID?: string) { const policy = deprecatedAllPolicies?.[`${ONYXKEYS.COLLECTION.POLICY}${policyID}`]; const workspaceChats = ReportUtils.getAllWorkspaceReports(policyID); - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array< + OnyxUpdate + > = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -1067,14 +1069,14 @@ function leaveWorkspace(policyID?: string) { }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, value: null, }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -1176,7 +1178,7 @@ function addBillingCardAndRequestPolicyOwnerChange( const {cardNumber, cardYear, cardMonth, cardCVV, addressName, addressZip, currency} = cardData; - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -1189,7 +1191,7 @@ function addBillingCardAndRequestPolicyOwnerChange( }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -1203,7 +1205,7 @@ function addBillingCardAndRequestPolicyOwnerChange( }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -1248,7 +1250,7 @@ function addBillingCardAndRequestPolicyOwnerChange( * */ function verifySetupIntentAndRequestPolicyOwnerChange(policyID: string) { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -1261,7 +1263,7 @@ function verifySetupIntentAndRequestPolicyOwnerChange(policyID: string) { }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -1275,7 +1277,7 @@ function verifySetupIntentAndRequestPolicyOwnerChange(policyID: string) { }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -1468,7 +1470,7 @@ function createPolicyExpenseChats( * Updates a workspace avatar image */ function updateWorkspaceAvatar(policyID: string, file: File) { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -1484,7 +1486,7 @@ function updateWorkspaceAvatar(policyID: string, file: File) { }, }, ]; - const finallyData: OnyxUpdate[] = [ + const finallyData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -1495,7 +1497,7 @@ function updateWorkspaceAvatar(policyID: string, file: File) { }, }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -1520,7 +1522,7 @@ function deleteWorkspaceAvatar(policyID: string) { // This will be fixed as part of https://github.com/Expensify/Expensify/issues/507850 // eslint-disable-next-line @typescript-eslint/no-deprecated const policy = getPolicy(policyID); - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -1536,7 +1538,7 @@ function deleteWorkspaceAvatar(policyID: string) { }, }, ]; - const finallyData: OnyxUpdate[] = [ + const finallyData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -1547,7 +1549,7 @@ function deleteWorkspaceAvatar(policyID: string) { }, }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -1626,7 +1628,7 @@ function updateGeneralSettings(policyID: string | undefined, name: string, curre } } - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { // We use SET because it's faster than merge and avoids a race condition when setting the currency and navigating the user to the Bank account page in confirmCurrencyChangeAndHideModal onyxMethod: Onyx.METHOD.SET, @@ -1659,7 +1661,7 @@ function updateGeneralSettings(policyID: string | undefined, name: string, curre }, }, ]; - const finallyData: OnyxUpdate[] = [ + const finallyData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -1688,7 +1690,7 @@ function updateGeneralSettings(policyID: string | undefined, name: string, curre errorFields.outputCurrency = ErrorUtils.getMicroSecondOnyxErrorWithTranslationKey('workspace.editor.genericFailureMessage'); } - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -1747,7 +1749,7 @@ function updateWorkspaceDescription(policyID: string, description: string, curre } const parsedDescription = ReportUtils.getParsedComment(description); - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -1762,7 +1764,7 @@ function updateWorkspaceDescription(policyID: string, description: string, curre }, }, ]; - const finallyData: OnyxUpdate[] = [ + const finallyData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -1773,7 +1775,7 @@ function updateWorkspaceDescription(policyID: string, description: string, curre }, }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -1830,7 +1832,7 @@ function updateAddress(policyID: string, newAddress: CompanyAddress) { 'data[zipCode]': newAddress.zipCode, }; - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -1843,7 +1845,7 @@ function updateAddress(policyID: string, newAddress: CompanyAddress) { }, ]; - const finallyData: OnyxUpdate[] = [ + const finallyData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -2020,7 +2022,7 @@ function createDraftInitialWorkspace( const shouldEnableWorkflowsByDefault = !introSelected?.choice || introSelected.choice === CONST.ONBOARDING_CHOICES.MANAGE_TEAM || introSelected.choice === CONST.ONBOARDING_CHOICES.LOOKING_AROUND; - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.SET, key: `${ONYXKEYS.COLLECTION.POLICY_DRAFTS}${policyID}`, @@ -2596,7 +2598,7 @@ function createDraftWorkspace( const shouldEnableWorkflowsByDefault = !introSelected?.choice || introSelected.choice === CONST.ONBOARDING_CHOICES.MANAGE_TEAM || introSelected.choice === CONST.ONBOARDING_CHOICES.LOOKING_AROUND; - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.SET, key: `${ONYXKEYS.COLLECTION.POLICY_DRAFTS}${policyID}`, @@ -3045,7 +3047,7 @@ function openPolicyReceiptPartnersPage(policyID?: string) { } function removePolicyReceiptPartnersConnection(policyID: string, partnerName: string, receiptPartnerData?: UberReceiptPartner) { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -3057,7 +3059,7 @@ function removePolicyReceiptPartnersConnection(policyID: string, partnerName: st }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -3069,7 +3071,7 @@ function removePolicyReceiptPartnersConnection(policyID: string, partnerName: st }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -3094,7 +3096,7 @@ function togglePolicyUberAutoInvite(policyID: string | undefined, enabled: boole return; } - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, onyxMethod: Onyx.METHOD.MERGE, @@ -3103,14 +3105,14 @@ function togglePolicyUberAutoInvite(policyID: string | undefined, enabled: boole }, }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, onyxMethod: Onyx.METHOD.MERGE, value: {receiptPartners: {uber: {pendingFields: {autoInvite: null}}}}, }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, onyxMethod: Onyx.METHOD.MERGE, @@ -3129,7 +3131,7 @@ function changePolicyUberBillingAccount(policyID: string | undefined, email: str return; } - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, onyxMethod: Onyx.METHOD.MERGE, @@ -3138,14 +3140,14 @@ function changePolicyUberBillingAccount(policyID: string | undefined, email: str }, }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, onyxMethod: Onyx.METHOD.MERGE, value: {receiptPartners: {uber: {pendingFields: {centralBillingAccountEmail: null}}}}, }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, onyxMethod: Onyx.METHOD.MERGE, @@ -3164,7 +3166,7 @@ function togglePolicyUberAutoRemove(policyID: string | undefined, enabled: boole return; } - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, onyxMethod: Onyx.METHOD.MERGE, @@ -3173,14 +3175,14 @@ function togglePolicyUberAutoRemove(policyID: string | undefined, enabled: boole }, }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, onyxMethod: Onyx.METHOD.MERGE, value: {receiptPartners: {uber: {pendingFields: {autoRemove: null}}}}, }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, onyxMethod: Onyx.METHOD.MERGE, @@ -3232,7 +3234,7 @@ function inviteWorkspaceEmployeesToUber(policyID: string, emails: string[]) { return acc; }, {}); - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -3245,7 +3247,7 @@ function inviteWorkspaceEmployeesToUber(policyID: string, emails: string[]) { }, }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -3258,7 +3260,7 @@ function inviteWorkspaceEmployeesToUber(policyID: string, emails: string[]) { }, }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -3323,7 +3325,7 @@ function openPolicyTaxesPage(policyID: string) { function openPolicyExpensifyCardsPage(policyID: string, workspaceAccountID: number) { const authToken = NetworkStore.getAuthToken(); - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.PRIVATE_EXPENSIFY_CARD_SETTINGS}${workspaceAccountID}`, @@ -3333,7 +3335,7 @@ function openPolicyExpensifyCardsPage(policyID: string, workspaceAccountID: numb }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.PRIVATE_EXPENSIFY_CARD_SETTINGS}${workspaceAccountID}`, @@ -3343,7 +3345,7 @@ function openPolicyExpensifyCardsPage(policyID: string, workspaceAccountID: numb }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.PRIVATE_EXPENSIFY_CARD_SETTINGS}${workspaceAccountID}`, @@ -3424,7 +3426,7 @@ function updateMemberCustomField(policyID: string, login: string, customFieldTyp return; } - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, onyxMethod: Onyx.METHOD.MERGE, @@ -3433,7 +3435,7 @@ function updateMemberCustomField(policyID: string, login: string, customFieldTyp }, }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, onyxMethod: Onyx.METHOD.MERGE, @@ -3442,7 +3444,7 @@ function updateMemberCustomField(policyID: string, login: string, customFieldTyp }, }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, onyxMethod: Onyx.METHOD.MERGE, @@ -3713,7 +3715,9 @@ function createWorkspaceFromIOUPayment( ]; successData.push(...employeeWorkspaceChat.onyxSuccessData); - const failureData: OnyxUpdate[] = [ + const failureData: Array< + OnyxUpdate + > = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${adminsChatReportID}`, @@ -5687,7 +5691,7 @@ function setPolicyDefaultReportTitle(policyID: string, customName: string) { const previousReportTitleField = policy?.fieldList?.[CONST.POLICY.FIELDS.FIELD_LIST_TITLE] ?? {}; - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -5702,7 +5706,7 @@ function setPolicyDefaultReportTitle(policyID: string, customName: string) { }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -5715,7 +5719,7 @@ function setPolicyDefaultReportTitle(policyID: string, customName: string) { }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -5762,7 +5766,7 @@ function setPolicyPreventMemberCreatedTitle(policyID: string, enforced: boolean) const previousReportTitleField = policy?.fieldList?.[CONST.POLICY.FIELDS.FIELD_LIST_TITLE] ?? {}; - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -5774,7 +5778,7 @@ function setPolicyPreventMemberCreatedTitle(policyID: string, enforced: boolean) }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -5787,7 +5791,7 @@ function setPolicyPreventMemberCreatedTitle(policyID: string, enforced: boolean) }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -5828,7 +5832,7 @@ function setPolicyPreventSelfApproval(policyID: string, preventSelfApproval: boo return; } - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -5841,7 +5845,7 @@ function setPolicyPreventSelfApproval(policyID: string, preventSelfApproval: boo }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -5854,7 +5858,7 @@ function setPolicyPreventSelfApproval(policyID: string, preventSelfApproval: boo }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -5899,7 +5903,7 @@ function setPolicyAutomaticApprovalLimit(policyID: string, limit: string) { return; } - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -5912,7 +5916,7 @@ function setPolicyAutomaticApprovalLimit(policyID: string, limit: string) { }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -5927,7 +5931,7 @@ function setPolicyAutomaticApprovalLimit(policyID: string, limit: string) { }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -5974,7 +5978,7 @@ function setPolicyAutomaticApprovalRate(policyID: string, auditRate: string) { return; } - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -5989,7 +5993,7 @@ function setPolicyAutomaticApprovalRate(policyID: string, auditRate: string) { }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -6004,7 +6008,7 @@ function setPolicyAutomaticApprovalRate(policyID: string, auditRate: string) { }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -6053,7 +6057,7 @@ function enableAutoApprovalOptions(policyID: string, enabled: boolean) { limit: enabled ? CONST.POLICY.AUTO_APPROVE_REPORTS_UNDER_SUGGESTED_CENTS : 0, }; const autoApprovalFailureValues = {autoApproval: {limit: policy?.autoApproval?.limit, auditRate: policy?.autoApproval?.auditRate, pendingFields: null}}; - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -6073,7 +6077,7 @@ function enableAutoApprovalOptions(policyID: string, enabled: boolean) { }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -6086,7 +6090,7 @@ function enableAutoApprovalOptions(policyID: string, enabled: boolean) { }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -6128,7 +6132,7 @@ function setPolicyAutoReimbursementLimit(policyID: string, limit: string) { return; } - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -6143,7 +6147,7 @@ function setPolicyAutoReimbursementLimit(policyID: string, limit: string) { }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -6159,7 +6163,7 @@ function setPolicyAutoReimbursementLimit(policyID: string, limit: string) { }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -6201,7 +6205,7 @@ function enablePolicyAutoReimbursementLimit(policyID: string, enabled: boolean) const autoReimbursementFailureValues = {autoReimbursement: {limit: policy?.autoReimbursement?.limit, pendingFields: null}}; const autoReimbursementValues = {limit: enabled ? CONST.POLICY.AUTO_REIMBURSEMENT_LIMIT_SUGGESTED_CENTS : CONST.POLICY.AUTO_REIMBURSEMENT_LIMIT_DEFAULT_CENTS}; - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -6220,7 +6224,7 @@ function enablePolicyAutoReimbursementLimit(policyID: string, enabled: boolean) }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -6234,7 +6238,7 @@ function enablePolicyAutoReimbursementLimit(policyID: string, enabled: boolean) }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -6280,7 +6284,7 @@ function updateInvoiceCompanyName(policyID: string, companyName: string) { // eslint-disable-next-line @typescript-eslint/no-deprecated const policy = getPolicy(policyID); - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -6295,7 +6299,7 @@ function updateInvoiceCompanyName(policyID: string, companyName: string) { }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -6309,7 +6313,7 @@ function updateInvoiceCompanyName(policyID: string, companyName: string) { }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -6344,7 +6348,7 @@ function updateInvoiceCompanyWebsite(policyID: string, companyWebsite: string) { // eslint-disable-next-line @typescript-eslint/no-deprecated const policy = getPolicy(policyID); - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -6359,7 +6363,7 @@ function updateInvoiceCompanyWebsite(policyID: string, companyWebsite: string) { }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -6373,7 +6377,7 @@ function updateInvoiceCompanyWebsite(policyID: string, companyWebsite: string) { }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -6401,7 +6405,7 @@ function updateInvoiceCompanyWebsite(policyID: string, companyWebsite: string) { * Validates user account and returns a list of accessible policies. */ function getAccessiblePolicies(validateCode?: string) { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.VALIDATE_USER_AND_GET_ACCESSIBLE_POLICIES, @@ -6412,7 +6416,7 @@ function getAccessiblePolicies(validateCode?: string) { }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.VALIDATE_USER_AND_GET_ACCESSIBLE_POLICIES, @@ -6423,7 +6427,7 @@ function getAccessiblePolicies(validateCode?: string) { }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.VALIDATE_USER_AND_GET_ACCESSIBLE_POLICIES, @@ -6449,21 +6453,21 @@ function clearGetAccessiblePoliciesErrors() { * Call the API to calculate the bill for the new dot */ function calculateBillNewDot() { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.IS_LOADING_BILL_WHEN_DOWNGRADE, value: true, }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.IS_LOADING_BILL_WHEN_DOWNGRADE, value: false, }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.IS_LOADING_BILL_WHEN_DOWNGRADE, @@ -6483,7 +6487,7 @@ function calculateBillNewDot() { * Call the API to pay and downgrade */ function payAndDowngrade() { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.BILLING_RECEIPT_DETAILS, @@ -6493,7 +6497,7 @@ function payAndDowngrade() { }, }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.BILLING_RECEIPT_DETAILS, @@ -6503,7 +6507,7 @@ function payAndDowngrade() { }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.BILLING_RECEIPT_DETAILS, diff --git a/src/libs/actions/Report.ts b/src/libs/actions/Report.ts index 0f4582fae1dda..7dd6b56818fa3 100644 --- a/src/libs/actions/Report.ts +++ b/src/libs/actions/Report.ts @@ -661,7 +661,7 @@ function addActions(reportID: string, notifyReportID: string, ancestors: Ancesto successReportActions[actionKey] = {pendingAction: null, isOptimisticAction: null}; } - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`, @@ -695,7 +695,7 @@ function addActions(reportID: string, notifyReportID: string, ancestors: Ancesto }; } - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, @@ -781,7 +781,7 @@ function reportActionsExist(reportID: string): boolean { } function updateChatName(reportID: string, reportName: string, type: typeof CONST.REPORT.CHAT_TYPE.GROUP | typeof CONST.REPORT.CHAT_TYPE.TRIP_ROOM) { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, @@ -797,7 +797,7 @@ function updateChatName(reportID: string, reportName: string, type: typeof CONST }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, @@ -808,7 +808,7 @@ function updateChatName(reportID: string, reportName: string, type: typeof CONST }, }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, @@ -837,7 +837,7 @@ function updateChatName(reportID: string, reportName: string, type: typeof CONST */ function buildUpdateReportAvatarOnyxData(reportID: string, file?: File | CustomRNImageManipulatorResult) { // If we have no file that means we are removing the avatar. - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, @@ -854,7 +854,7 @@ function buildUpdateReportAvatarOnyxData(reportID: string, file?: File | CustomR ]; const fetchedReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${reportID}`]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, @@ -867,7 +867,7 @@ function buildUpdateReportAvatarOnyxData(reportID: string, file?: File | CustomR }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, @@ -1053,7 +1053,7 @@ function openReport( }); } - const finallyData: OnyxUpdate[] = []; + const finallyData: Array> = []; const parameters: OpenReportParams = { reportID, @@ -1563,7 +1563,7 @@ function getOlderActions(reportID: string | undefined, reportActionID: string | return; } - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_METADATA}${reportID}`, @@ -1574,7 +1574,7 @@ function getOlderActions(reportID: string | undefined, reportActionID: string | }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_METADATA}${reportID}`, @@ -1584,7 +1584,7 @@ function getOlderActions(reportID: string | undefined, reportActionID: string | }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_METADATA}${reportID}`, @@ -1621,7 +1621,7 @@ function getNewerActions(reportID: string | undefined, reportActionID: string | return; } - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_METADATA}${reportID}`, @@ -1632,7 +1632,7 @@ function getNewerActions(reportID: string | undefined, reportActionID: string | }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_METADATA}${reportID}`, @@ -1642,7 +1642,7 @@ function getNewerActions(reportID: string | undefined, reportActionID: string | }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_METADATA}${reportID}`, @@ -1697,7 +1697,7 @@ function readNewestAction(reportID: string | undefined, shouldResetUnreadMarker const lastReadTime = NetworkConnection.getDBTimeWithSkew(); - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, @@ -1822,7 +1822,7 @@ function markCommentAsUnread(reportID: string | undefined, reportAction: ReportA // Since the report action with ID 100 will be the first with a timestamp above '2014-04-01 16:07:02.998', it's the first one that will be shown as unread const lastReadTime = DateUtils.subtractMillisecondsFromDateTime(actionCreationTime, 1); - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, @@ -1851,7 +1851,7 @@ function togglePinnedState(reportID: string | undefined, isPinnedChat: boolean) const pinnedValue = !isPinnedChat; // Optimistically pin/unpin the report before we send out the command - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, @@ -2023,7 +2023,7 @@ function deleteReportComment( } // If the API call fails we must show the original message again, so we revert the message content back to how it was // and and remove the pendingAction so the strike-through clears - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${originalReportID}`, @@ -2037,7 +2037,7 @@ function deleteReportComment( }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${originalReportID}`, @@ -2208,7 +2208,7 @@ function editReportComment( }, }; - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${originalReportID}`, @@ -2229,7 +2229,7 @@ function editReportComment( }); } - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${originalReportID}`, @@ -2242,7 +2242,7 @@ function editReportComment( }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${originalReportID}`, @@ -2300,7 +2300,7 @@ function updateNotificationPreference( return; } - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, @@ -2314,7 +2314,7 @@ function updateNotificationPreference( }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, @@ -2351,7 +2351,7 @@ function updateRoomVisibility(reportID: string, previousValue: RoomVisibility | return; } - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, @@ -2359,7 +2359,7 @@ function updateRoomVisibility(reportID: string, previousValue: RoomVisibility | }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, @@ -2416,7 +2416,7 @@ function toggleSubscribeToChildReport( } function updateReportName(reportID: string, value: string, previousValue: string) { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, @@ -2428,7 +2428,7 @@ function updateReportName(reportID: string, value: string, previousValue: string }, }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, @@ -2444,7 +2444,7 @@ function updateReportName(reportID: string, value: string, previousValue: string }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, @@ -2522,7 +2522,15 @@ function updateReportField( isASAPSubmitBetaEnabled, }); - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array< + OnyxUpdate< + | typeof ONYXKEYS.COLLECTION.REPORT + | typeof ONYXKEYS.COLLECTION.NEXT_STEP + | typeof ONYXKEYS.COLLECTION.REPORT_ACTIONS + | typeof ONYXKEYS.COLLECTION.REPORT_VIOLATIONS + | typeof ONYXKEYS.RECENTLY_USED_REPORT_FIELDS + > + > = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, @@ -2573,7 +2581,7 @@ function updateReportField( }); } - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, @@ -2612,7 +2620,7 @@ function updateReportField( }); } - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, @@ -2649,7 +2657,7 @@ function updateReportField( function deleteReportField(reportID: string, reportField: PolicyReportField) { const fieldKey = getReportFieldKey(reportField.fieldID); - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, @@ -2664,7 +2672,7 @@ function deleteReportField(reportID: string, reportField: PolicyReportField) { }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, @@ -2682,7 +2690,7 @@ function deleteReportField(reportID: string, reportField: PolicyReportField) { }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, @@ -2715,7 +2723,7 @@ function updateDescription(reportID: string, currentDescription: string, newMark const optimisticDescriptionUpdatedReportAction = buildOptimisticRoomDescriptionUpdatedReportAction(parsedDescription); const report = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${reportID}`]; - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, @@ -2735,7 +2743,7 @@ function updateDescription(reportID: string, currentDescription: string, newMark }, }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, @@ -2755,7 +2763,7 @@ function updateDescription(reportID: string, currentDescription: string, newMark }, }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, @@ -2781,14 +2789,14 @@ function updateWriteCapability(report: Report, newValue: WriteCapability) { return; } - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${report.reportID}`, value: {writeCapability: newValue}, }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${report.reportID}`, @@ -2965,7 +2973,7 @@ function buildNewReportOptimisticData( }); } - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, @@ -2985,7 +2993,7 @@ function buildNewReportOptimisticData( }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, @@ -3098,7 +3106,9 @@ function addPolicyReport(policyReport: OptimisticChatReport) { // Onyx.set is used on the optimistic data so that it is present before navigating to the workspace room. With Onyx.merge the workspace room reportID is not present when // fetchReportIfNeeded is called on the ReportScreen, so openReport is called which is unnecessary since the optimistic data will be stored in Onyx. // Therefore, Onyx.set is used instead of Onyx.merge. - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array< + OnyxUpdate + > = [ { onyxMethod: Onyx.METHOD.SET, key: `${ONYXKEYS.COLLECTION.REPORT}${policyReport.reportID}`, @@ -3127,7 +3137,9 @@ function addPolicyReport(policyReport: OptimisticChatReport) { }, }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array< + OnyxUpdate + > = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${policyReport.reportID}`, @@ -3159,7 +3171,7 @@ function addPolicyReport(policyReport: OptimisticChatReport) { value: {isLoading: false}, }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${policyReport.reportID}`, @@ -3280,7 +3292,7 @@ function updatePolicyRoomName(policyRoomReport: Report, policyRoomName: string) const optimisticRenamedAction = buildOptimisticRenamedRoomReportAction(policyRoomName, previousName ?? ''); - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, @@ -3302,7 +3314,7 @@ function updatePolicyRoomName(policyRoomReport: Report, policyRoomName: string) }, }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, @@ -3318,7 +3330,7 @@ function updatePolicyRoomName(policyRoomReport: Report, policyRoomName: string) value: {[optimisticRenamedAction.reportActionID]: {pendingAction: null}}, }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, @@ -3467,7 +3479,7 @@ function clearIOUError(reportID: string | undefined) { */ function addEmojiReaction(reportID: string, reportActionID: string, emoji: Emoji, skinTone: number) { const createdAt = timezoneFormat(toZonedTime(new Date(), 'UTC'), CONST.DATE.FNS_DB_FORMAT_STRING); - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS_REACTIONS}${reportActionID}`, @@ -3487,7 +3499,7 @@ function addEmojiReaction(reportID: string, reportActionID: string, emoji: Emoji }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS_REACTIONS}${reportActionID}`, @@ -3499,7 +3511,7 @@ function addEmojiReaction(reportID: string, reportActionID: string, emoji: Emoji }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS_REACTIONS}${reportActionID}`, @@ -3527,7 +3539,7 @@ function addEmojiReaction(reportID: string, reportActionID: string, emoji: Emoji * Uses the NEW FORMAT for "emojiReactions" */ function removeEmojiReaction(reportID: string, reportActionID: string, emoji: Emoji) { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS_REACTIONS}${reportActionID}`, @@ -3647,7 +3659,7 @@ function leaveGroupChat(reportID: string, shouldClearQuickAction: boolean) { // Use merge instead of set to avoid deleting the report too quickly, which could cause a brief "not found" page to appear. // The remaining parts of the report object will be removed after the API call is successful. - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, @@ -3677,7 +3689,7 @@ function leaveGroupChat(reportID: string, shouldClearQuickAction: boolean) { // Ensure that any remaining data is removed upon successful completion, even if the server sends a report removal response. // This is done to prevent the removal update from lingering in the applyHTTPSOnyxUpdates function. - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, @@ -3685,7 +3697,7 @@ function leaveGroupChat(reportID: string, shouldClearQuickAction: boolean) { }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, @@ -3723,7 +3735,7 @@ function leaveRoom(reportID: string, isWorkspaceMemberLeavingWorkspaceRoom = fal // If a workspace member is leaving a workspace room, they don't actually lose the room from Onyx. // Instead, their notification preference just gets set to "hidden". // Same applies for chat threads too - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, @@ -3752,7 +3764,7 @@ function leaveRoom(reportID: string, isWorkspaceMemberLeavingWorkspaceRoom = fal }, ]; - const successData: OnyxUpdate[] = []; + const successData: Array> = []; if (isWorkspaceMemberLeavingWorkspaceRoom || isChatThread) { successData.push({ onyxMethod: Onyx.METHOD.MERGE, @@ -3775,7 +3787,7 @@ function leaveRoom(reportID: string, isWorkspaceMemberLeavingWorkspaceRoom = fal }); } - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, @@ -3905,7 +3917,7 @@ function buildInviteToRoomOnyxData(reportID: string, inviteeEmailsToAccountIDs: ]; successData.push(...newPersonalDetailsOnyxData.finallyData); - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_METADATA}${reportID}`, @@ -3996,7 +4008,7 @@ function updateGroupChatMemberRoles(reportID: string, accountIDList: number[], r }; } - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, @@ -4004,7 +4016,7 @@ function updateGroupChatMemberRoles(reportID: string, accountIDList: number[], r }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, @@ -4036,7 +4048,7 @@ function removeFromRoom(reportID: string, targetAccountIDs: number[]) { } const pendingChatMembers = getPendingChatMembers(targetAccountIDs, reportMetadata?.pendingChatMembers ?? [], CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE); - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_METADATA}${reportID}`, @@ -4046,7 +4058,7 @@ function removeFromRoom(reportID: string, targetAccountIDs: number[]) { }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_METADATA}${reportID}`, @@ -4058,7 +4070,7 @@ function removeFromRoom(reportID: string, targetAccountIDs: number[]) { // We need to add success data here since in high latency situations, // the OpenRoomMembersPage call has the chance of overwriting the optimistic data we set above. - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, @@ -4152,7 +4164,7 @@ function flagComment(reportAction: OnyxEntry, severity: string, or ...(shouldHideMessage ? {translationKey: '', type: 'COMMENT', html: '', text: '', isEdited: true} : {}), }; - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${originalReportID}`, @@ -4189,7 +4201,7 @@ function flagComment(reportAction: OnyxEntry, severity: string, or }); } - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${originalReportID}`, @@ -4211,7 +4223,7 @@ function flagComment(reportAction: OnyxEntry, severity: string, or }); } - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${originalReportID}`, @@ -4236,7 +4248,7 @@ function flagComment(reportAction: OnyxEntry, severity: string, or /** Updates a given user's private notes on a report */ const updatePrivateNotes = (reportID: string, accountID: number, note: string) => { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, @@ -4252,7 +4264,7 @@ const updatePrivateNotes = (reportID: string, accountID: number, note: string) = }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, @@ -4267,7 +4279,7 @@ const updatePrivateNotes = (reportID: string, accountID: number, note: string) = }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, @@ -4296,7 +4308,7 @@ function getReportPrivateNote(reportID: string | undefined) { return; } - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_METADATA}${reportID}`, @@ -4306,7 +4318,7 @@ function getReportPrivateNote(reportID: string | undefined) { }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_METADATA}${reportID}`, @@ -4316,7 +4328,7 @@ function getReportPrivateNote(reportID: string | undefined) { }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_METADATA}${reportID}`, @@ -4456,7 +4468,7 @@ function searchForReports(isOffline: boolean, searchInput: string, policyID?: st return; } - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.IS_SEARCHING_FOR_REPORTS, @@ -4464,7 +4476,7 @@ function searchForReports(isOffline: boolean, searchInput: string, policyID?: st }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.IS_SEARCHING_FOR_REPORTS, @@ -4569,7 +4581,7 @@ function resolveActionableMentionWhisper( lastActorAccountID: report?.lastActorAccountID, }; - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`, @@ -4589,7 +4601,7 @@ function resolveActionableMentionWhisper( }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`, @@ -4653,7 +4665,7 @@ function resolveActionableReportMentionWhisper( lastActorAccountID: report?.lastActorAccountID, }; - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportId}`, @@ -4672,7 +4684,7 @@ function resolveActionableReportMentionWhisper( }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportId}`, @@ -4711,7 +4723,7 @@ function dismissTrackExpenseActionableWhisper(reportID: string | undefined, repo resolution: CONST.REPORT.ACTIONABLE_TRACK_EXPENSE_WHISPER_RESOLUTION.NOTHING, }; - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`, @@ -4726,7 +4738,7 @@ function dismissTrackExpenseActionableWhisper(reportID: string | undefined, repo }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`, @@ -4756,7 +4768,7 @@ function exportToIntegration(reportID: string, connectionName: ConnectionName) { const action = buildOptimisticExportIntegrationAction(connectionName); const optimisticReportActionID = action.reportActionID; - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`, @@ -4766,7 +4778,7 @@ function exportToIntegration(reportID: string, connectionName: ConnectionName) { }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`, @@ -4795,7 +4807,7 @@ function markAsManuallyExported(reportID: string, connectionName: ConnectionName const label = CONST.POLICY.CONNECTIONS.NAME_USER_FRIENDLY[connectionName]; const optimisticReportActionID = action.reportActionID; - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`, @@ -4805,7 +4817,7 @@ function markAsManuallyExported(reportID: string, connectionName: ConnectionName }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`, @@ -4817,7 +4829,7 @@ function markAsManuallyExported(reportID: string, connectionName: ConnectionName }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`, @@ -4868,7 +4880,7 @@ function exportReportToCSV({reportID, transactionIDList}: ExportReportCSVParams, } function exportReportToPDF({reportID}: ExportReportPDFParams) { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.SET, key: `${ONYXKEYS.COLLECTION.NVP_EXPENSIFY_REPORT_PDF_FILENAME}${reportID}`, @@ -4876,7 +4888,7 @@ function exportReportToPDF({reportID}: ExportReportPDFParams) { }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.NVP_EXPENSIFY_REPORT_PDF_FILENAME}${reportID}`, @@ -4914,9 +4926,19 @@ function deleteAppReport(reportID: string | undefined, currentUserEmailParam: st Log.warn('[Report] deleteReport called with no reportID'); return; } - const optimisticData: OnyxUpdate[] = []; - const successData: OnyxUpdate[] = []; - const failureData: OnyxUpdate[] = []; + const optimisticData: Array< + OnyxUpdate< + | typeof ONYXKEYS.COLLECTION.REPORT + | typeof ONYXKEYS.COLLECTION.REPORT_METADATA + | typeof ONYXKEYS.COLLECTION.REPORT_ACTIONS + | typeof ONYXKEYS.COLLECTION.TRANSACTION + | typeof ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS + > + > = []; + const successData: Array> = []; + const failureData: Array< + OnyxUpdate + > = []; const report = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${reportID}`]; @@ -5440,9 +5462,9 @@ function moveIOUReportToPolicyAndInviteSubmitter( } function convertIOUReportToExpenseReport(iouReport: Report, policy: Policy, policyID: string, optimisticPolicyExpenseChatReportID: string) { - const optimisticData: OnyxUpdate[] = []; - const successData: OnyxUpdate[] = []; - const failureData: OnyxUpdate[] = []; + const optimisticData: Array> = []; + const successData: Array> = []; + const failureData: Array> = []; const expenseReport = { ...iouReport, @@ -5689,8 +5711,10 @@ function buildOptimisticChangePolicyData( optimisticPolicyExpenseChatReport?: Report, ) { const optimisticData: OnyxUpdate[] = []; - const successData: OnyxUpdate[] = []; - const failureData: OnyxUpdate[] = []; + const successData: Array> = []; + const failureData: Array< + OnyxUpdate + > = []; // 1. Optimistically set the policyID on the report (and all its threads) by: // 1.1 Preprocess reports to create a map of parentReportID to child reports list of reportIDs diff --git a/src/libs/actions/ReportLayout.ts b/src/libs/actions/ReportLayout.ts index 9754787baec86..4ad7b6621cf5e 100644 --- a/src/libs/actions/ReportLayout.ts +++ b/src/libs/actions/ReportLayout.ts @@ -10,7 +10,7 @@ import type {ReportLayoutGroupBy} from '@src/types/onyx'; * Set the user's report layout group-by preference */ function setReportLayoutGroupBy(groupBy: ReportLayoutGroupBy, previousValue?: string | null) { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.NVP_REPORT_LAYOUT_GROUP_BY, @@ -18,7 +18,7 @@ function setReportLayoutGroupBy(groupBy: ReportLayoutGroupBy, previousValue?: st }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.NVP_REPORT_LAYOUT_GROUP_BY, diff --git a/src/libs/actions/RequestConflictUtils.ts b/src/libs/actions/RequestConflictUtils.ts index 93397955f16a8..b1b239df562b9 100644 --- a/src/libs/actions/RequestConflictUtils.ts +++ b/src/libs/actions/RequestConflictUtils.ts @@ -138,7 +138,7 @@ function resolveCommentDeletionConflicts(persistedRequests: OnyxRequest[], repor if (addCommentFound) { // The new message performs some changes in Onyx, so we need to rollback those changes. - const rollbackData: OnyxUpdate[] = [ + const rollbackData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${originalReportID}`, diff --git a/src/libs/actions/ScheduleCall.ts b/src/libs/actions/ScheduleCall.ts index d33e57ceeb548..9d915785a03d4 100644 --- a/src/libs/actions/ScheduleCall.ts +++ b/src/libs/actions/ScheduleCall.ts @@ -15,7 +15,7 @@ function getGuideCallAvailabilitySchedule(reportID: string) { return; } - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${reportID}`, @@ -28,7 +28,7 @@ function getGuideCallAvailabilitySchedule(reportID: string) { }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${reportID}`, @@ -41,7 +41,7 @@ function getGuideCallAvailabilitySchedule(reportID: string) { }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${reportID}`, diff --git a/src/libs/actions/Search.ts b/src/libs/actions/Search.ts index 6d80f72fdfe0a..b4b9f753e9aef 100644 --- a/src/libs/actions/Search.ts +++ b/src/libs/actions/Search.ts @@ -217,7 +217,7 @@ function getOnyxLoadingData( isOffline?: boolean, isSearchAPI = false, ): {optimisticData: OnyxUpdate[]; finallyData: OnyxUpdate[]; failureData: OnyxUpdate[]} { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.SNAPSHOT}${hash}`, @@ -237,7 +237,7 @@ function getOnyxLoadingData( }, ]; - const finallyData: OnyxUpdate[] = [ + const finallyData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.SNAPSHOT}${hash}`, @@ -249,7 +249,7 @@ function getOnyxLoadingData( }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ // @ts-expect-error - will be solved in https://github.com/Expensify/App/issues/73830 { onyxMethod: Onyx.METHOD.MERGE, @@ -273,7 +273,7 @@ function saveSearch({queryJSON, newName}: {queryJSON: SearchQueryJSON; newName?: const saveSearchName = newName ?? queryJSON?.inputQuery ?? ''; const jsonQuery = JSON.stringify(queryJSON); - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.SAVED_SEARCHES}`, @@ -287,7 +287,7 @@ function saveSearch({queryJSON, newName}: {queryJSON: SearchQueryJSON; newName?: }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.SAVED_SEARCHES}`, @@ -297,7 +297,7 @@ function saveSearch({queryJSON, newName}: {queryJSON: SearchQueryJSON; newName?: }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.SAVED_SEARCHES}`, @@ -312,7 +312,7 @@ function saveSearch({queryJSON, newName}: {queryJSON: SearchQueryJSON; newName?: } function deleteSavedSearch(hash: number) { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.SAVED_SEARCHES}`, @@ -323,7 +323,7 @@ function deleteSavedSearch(hash: number) { }, }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.SAVED_SEARCHES}`, @@ -332,7 +332,7 @@ function deleteSavedSearch(hash: number) { }, }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.SAVED_SEARCHES}`, @@ -446,7 +446,7 @@ function holdMoneyRequestOnSearch(hash: number, transactionIDList: string[], com } function submitMoneyRequestOnSearch(hash: number, reportList: Report[], policy: Policy[], currentSearchKey?: SearchKey) { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE_COLLECTION, key: ONYXKEYS.COLLECTION.REPORT_METADATA, @@ -454,7 +454,7 @@ function submitMoneyRequestOnSearch(hash: number, reportList: Report[], policy: }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE_COLLECTION, key: ONYXKEYS.COLLECTION.REPORT_METADATA, @@ -473,7 +473,7 @@ function submitMoneyRequestOnSearch(hash: number, reportList: Report[], policy: }); } - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE_COLLECTION, key: ONYXKEYS.COLLECTION.REPORT_METADATA, @@ -501,7 +501,7 @@ function submitMoneyRequestOnSearch(hash: number, reportList: Report[], policy: } function approveMoneyRequestOnSearch(hash: number, reportIDList: string[], currentSearchKey?: SearchKey) { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE_COLLECTION, key: ONYXKEYS.COLLECTION.REPORT_METADATA, @@ -509,7 +509,7 @@ function approveMoneyRequestOnSearch(hash: number, reportIDList: string[], curre }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE_COLLECTION, key: ONYXKEYS.COLLECTION.REPORT_METADATA, @@ -529,7 +529,7 @@ function approveMoneyRequestOnSearch(hash: number, reportIDList: string[], curre }); } - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE_COLLECTION, key: ONYXKEYS.COLLECTION.REPORT_METADATA, @@ -553,7 +553,7 @@ function exportToIntegrationOnSearch(hash: number, reportID: string, connectionN const successAction: OptimisticExportIntegrationAction = {...optimisticAction, pendingAction: null}; const optimisticReportActionID = optimisticAction.reportActionID; - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_METADATA}${reportID}`, @@ -568,7 +568,7 @@ function exportToIntegrationOnSearch(hash: number, reportID: string, connectionN }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_METADATA}${reportID}`, @@ -596,7 +596,7 @@ function exportToIntegrationOnSearch(hash: number, reportID: string, connectionN }); } - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_METADATA}${reportID}`, @@ -629,7 +629,7 @@ function exportToIntegrationOnSearch(hash: number, reportID: string, connectionN } function payMoneyRequestOnSearch(hash: number, paymentData: PaymentData[], currentSearchKey?: SearchKey) { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE_COLLECTION, key: ONYXKEYS.COLLECTION.REPORT_METADATA, @@ -637,7 +637,7 @@ function payMoneyRequestOnSearch(hash: number, paymentData: PaymentData[], curre }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE_COLLECTION, key: ONYXKEYS.COLLECTION.REPORT_METADATA, @@ -656,7 +656,7 @@ function payMoneyRequestOnSearch(hash: number, paymentData: PaymentData[], curre }); } - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE_COLLECTION, key: ONYXKEYS.COLLECTION.REPORT_METADATA, @@ -709,7 +709,7 @@ function deleteMoneyRequestOnSearch(hash: number, transactionIDList: string[]) { }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.SNAPSHOT}${hash}`, @@ -1152,7 +1152,7 @@ function setOptimisticDataForTransactionThreadPreview(item: TransactionListItemT const {reportID, report, amount, currency, transactionID, created, policyID} = item; const moneyRequestReportActionID = item?.reportAction?.reportActionID; const {hasParentReport, hasParentReportAction, hasTransaction, hasTransactionThreadReport} = transactionPreviewData; - const onyxUpdates: OnyxUpdate[] = []; + const onyxUpdates: Array> = []; // Set optimistic parent report if (!hasParentReport) { diff --git a/src/libs/actions/Session/index.ts b/src/libs/actions/Session/index.ts index 9b5e0618ee0ea..69a79d257c858 100644 --- a/src/libs/actions/Session/index.ts +++ b/src/libs/actions/Session/index.ts @@ -148,7 +148,7 @@ function setSupportAuthToken(supportAuthToken: string, email: string, accountID: } function getShortLivedLoginParams(isSupportAuthTokenUsed = false, isSAML = false) { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.ACCOUNT, @@ -170,7 +170,7 @@ function getShortLivedLoginParams(isSupportAuthTokenUsed = false, isSAML = false ]; // Subsequently, we revert it back to the default value of 'signedInWithShortLivedAuthToken' in 'finallyData' to ensure the user is logged out on refresh - const finallyData: OnyxUpdate[] = [ + const finallyData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.ACCOUNT, @@ -189,7 +189,7 @@ function getShortLivedLoginParams(isSupportAuthTokenUsed = false, isSAML = false }, ]; - const failureData: OnyxUpdate[] = []; + const failureData: Array> = []; if (CONFIG.IS_HYBRID_APP && isSAML) { optimisticData.push({ @@ -435,7 +435,7 @@ function callFunctionIfActionIsAllowed an * Request a new validate / magic code for user to sign in via passwordless flow */ function resendValidateCode(login = credentials.login) { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.ACCOUNT, @@ -445,7 +445,7 @@ function resendValidateCode(login = credentials.login) { }, }, ]; - const finallyData: OnyxUpdate[] = [ + const finallyData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.ACCOUNT, @@ -545,7 +545,7 @@ function buildOnyxDataToCleanUpAnonymousUser() { * */ function signUpUser(preferredLocale: Locale | undefined) { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.ACCOUNT, @@ -569,7 +569,7 @@ function signUpUser(preferredLocale: Locale | undefined) { onyxOperationToCleanUpAnonymousUser, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.ACCOUNT, @@ -713,7 +713,7 @@ function signInWithShortLivedAuthToken(authToken: string, isSAML = false) { * @param validateCode - 6 digit code required for login */ function signIn(validateCode: string, preferredLocale: Locale | undefined, twoFactorAuthCode?: string) { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.ACCOUNT, @@ -746,7 +746,7 @@ function signIn(validateCode: string, preferredLocale: Locale | undefined, twoFa onyxOperationToCleanUpAnonymousUser, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.ACCOUNT, @@ -780,7 +780,7 @@ function signInWithValidateCode(accountID: number, code: string, preferredLocale const validateCode = twoFactorAuthCode ? credentials.validateCode : code; const onyxOperationToCleanUpAnonymousUser = buildOnyxDataToCleanUpAnonymousUser(); - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.ACCOUNT, @@ -822,7 +822,7 @@ function signInWithValidateCode(accountID: number, code: string, preferredLocale onyxOperationToCleanUpAnonymousUser, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.ACCOUNT, @@ -1059,7 +1059,7 @@ function requestUnlinkValidationLink() { } function unlinkLogin(accountID: number, validateCode: string) { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.ACCOUNT, @@ -1069,7 +1069,7 @@ function unlinkLogin(accountID: number, validateCode: string) { }, }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.ACCOUNT, @@ -1086,7 +1086,7 @@ function unlinkLogin(accountID: number, validateCode: string) { }, }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.ACCOUNT, @@ -1112,7 +1112,7 @@ function unlinkLogin(accountID: number, validateCode: string) { * Toggles two-factor authentication based on the `enable` parameter */ function toggleTwoFactorAuth(enable: boolean, twoFactorAuthCode = '') { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.ACCOUNT, @@ -1122,7 +1122,7 @@ function toggleTwoFactorAuth(enable: boolean, twoFactorAuthCode = '') { }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.ACCOUNT, @@ -1132,7 +1132,7 @@ function toggleTwoFactorAuth(enable: boolean, twoFactorAuthCode = '') { }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.ACCOUNT, @@ -1293,7 +1293,7 @@ const canAnonymousUserAccessRoute = (route: string) => { }; function AddWorkEmail(workEmail: string) { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.FORMS.ONBOARDING_WORK_EMAIL_FORM, @@ -1304,7 +1304,7 @@ function AddWorkEmail(workEmail: string) { }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.FORMS.ONBOARDING_WORK_EMAIL_FORM, @@ -1314,7 +1314,7 @@ function AddWorkEmail(workEmail: string) { }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.FORMS.ONBOARDING_WORK_EMAIL_FORM, @@ -1343,7 +1343,7 @@ function AddWorkEmail(workEmail: string) { } function MergeIntoAccountAndLogin(workEmail: string | undefined, validateCode: string, accountID: number | undefined) { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.ONBOARDING_ERROR_MESSAGE_TRANSLATION_KEY, @@ -1359,7 +1359,7 @@ function MergeIntoAccountAndLogin(workEmail: string | undefined, validateCode: s }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.ONBOARDING_ERROR_MESSAGE_TRANSLATION_KEY, @@ -1382,7 +1382,7 @@ function MergeIntoAccountAndLogin(workEmail: string | undefined, validateCode: s }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.ACCOUNT, @@ -1432,7 +1432,7 @@ function MergeIntoAccountAndLogin(workEmail: string | undefined, validateCode: s function resetSMSDeliveryFailureStatus(login: string) { const params: ResetSMSDeliveryFailureStatusParams = {login}; - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.ACCOUNT, @@ -1444,7 +1444,7 @@ function resetSMSDeliveryFailureStatus(login: string) { }, }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.ACCOUNT, @@ -1455,7 +1455,7 @@ function resetSMSDeliveryFailureStatus(login: string) { }, }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.ACCOUNT, diff --git a/src/libs/actions/Subscription.ts b/src/libs/actions/Subscription.ts index 6d65f7b35501a..07b9346b860d6 100644 --- a/src/libs/actions/Subscription.ts +++ b/src/libs/actions/Subscription.ts @@ -16,7 +16,7 @@ function openSubscriptionPage() { } function updateSubscriptionType(type: SubscriptionType) { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.NVP_PRIVATE_SUBSCRIPTION, @@ -30,7 +30,7 @@ function updateSubscriptionType(type: SubscriptionType) { }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.NVP_PRIVATE_SUBSCRIPTION, @@ -44,7 +44,7 @@ function updateSubscriptionType(type: SubscriptionType) { }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.NVP_PRIVATE_SUBSCRIPTION, @@ -69,7 +69,7 @@ function updateSubscriptionType(type: SubscriptionType) { } function updateSubscriptionAutoRenew(autoRenew: boolean, disableAutoRenewReason?: FeedbackSurveyOptionID, disableAutoRenewAdditionalNote?: string) { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.NVP_PRIVATE_SUBSCRIPTION, @@ -83,7 +83,7 @@ function updateSubscriptionAutoRenew(autoRenew: boolean, disableAutoRenewReason? }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.NVP_PRIVATE_SUBSCRIPTION, @@ -96,7 +96,7 @@ function updateSubscriptionAutoRenew(autoRenew: boolean, disableAutoRenewReason? }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.NVP_PRIVATE_SUBSCRIPTION, @@ -123,7 +123,7 @@ function updateSubscriptionAutoRenew(autoRenew: boolean, disableAutoRenewReason? } function updateSubscriptionAddNewUsersAutomatically(addNewUsersAutomatically: boolean) { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.NVP_PRIVATE_SUBSCRIPTION, @@ -137,7 +137,7 @@ function updateSubscriptionAddNewUsersAutomatically(addNewUsersAutomatically: bo }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.NVP_PRIVATE_SUBSCRIPTION, @@ -150,7 +150,7 @@ function updateSubscriptionAddNewUsersAutomatically(addNewUsersAutomatically: bo }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.NVP_PRIVATE_SUBSCRIPTION, diff --git a/src/libs/actions/Task.ts b/src/libs/actions/Task.ts index a19af347ff4a6..f6e81e4e0174b 100644 --- a/src/libs/actions/Task.ts +++ b/src/libs/actions/Task.ts @@ -325,7 +325,7 @@ function buildTaskData( ) { const message = `marked as complete`; const completedTaskReportAction = ReportUtils.buildOptimisticTaskReportAction(taskReportID, CONST.REPORT.ACTIONS.TYPE.TASK_COMPLETED, message); - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${taskReportID}`, @@ -342,7 +342,7 @@ function buildTaskData( }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${taskReportID}`, @@ -354,7 +354,7 @@ function buildTaskData( }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${taskReportID}`, @@ -465,7 +465,7 @@ function reopenTask(taskReport: OnyxEntry, parentReport: OnyxE const reopenedTaskReportAction = ReportUtils.buildOptimisticTaskReportAction(taskReportID, CONST.REPORT.ACTIONS.TYPE.TASK_REOPENED, message); const hasOutstandingChildTask = taskReport?.managerID === currentUserAccountID ? true : parentReport?.hasOutstandingChildTask; - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${taskReportID}`, @@ -492,7 +492,7 @@ function reopenTask(taskReport: OnyxEntry, parentReport: OnyxE }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${taskReportID}`, @@ -503,7 +503,7 @@ function reopenTask(taskReport: OnyxEntry, parentReport: OnyxE }, }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${taskReportID}`, @@ -551,7 +551,7 @@ function editTask(report: OnyxTypes.Report, {title, description}: OnyxTypes.Task const newDescription = typeof description === 'string' ? ReportUtils.getParsedComment(description) : report.description; const reportDescription = (newDescription ?? '').trim(); - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report.reportID}`, @@ -572,7 +572,7 @@ function editTask(report: OnyxTypes.Report, {title, description}: OnyxTypes.Task }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report.reportID}`, @@ -592,7 +592,7 @@ function editTask(report: OnyxTypes.Report, {title, description}: OnyxTypes.Task }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report.reportID}`, @@ -1110,7 +1110,7 @@ function deleteTask( optimisticData.push(...ReportUtils.getOptimisticDataForAncestors(ancestors, parentReport?.lastVisibleActionCreated ?? '', CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE)); } - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report.reportID}`, @@ -1127,7 +1127,7 @@ function deleteTask( }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${report.reportID}`, diff --git a/src/libs/actions/TeachersUnite.ts b/src/libs/actions/TeachersUnite.ts index 880723ace21b4..3e838ae157de0 100644 --- a/src/libs/actions/TeachersUnite.ts +++ b/src/libs/actions/TeachersUnite.ts @@ -30,7 +30,7 @@ function referTeachersUniteVolunteer(partnerUserID: string, firstName: string, l chatType: CONST.REPORT.CHAT_TYPE.POLICY_ROOM, policyID, }); - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.SET, key: `${ONYXKEYS.COLLECTION.REPORT}${publicRoomReportID}`, @@ -98,7 +98,9 @@ function addSchoolPrincipal( reportActionID: expenseReportCreatedAction.reportActionID, }; - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array< + OnyxUpdate + > = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.FORMS.INTRO_SCHOOL_PRINCIPAL_FORM, @@ -144,7 +146,15 @@ function addSchoolPrincipal( }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array< + OnyxUpdate< + | typeof ONYXKEYS.FORMS.INTRO_SCHOOL_PRINCIPAL_FORM + | typeof ONYXKEYS.COLLECTION.POLICY + | typeof ONYXKEYS.COLLECTION.REPORT + | typeof ONYXKEYS.COLLECTION.REPORT_METADATA + | typeof ONYXKEYS.COLLECTION.REPORT_ACTIONS + > + > = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.FORMS.INTRO_SCHOOL_PRINCIPAL_FORM, @@ -185,7 +195,9 @@ function addSchoolPrincipal( }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array< + OnyxUpdate + > = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.FORMS.INTRO_SCHOOL_PRINCIPAL_FORM, diff --git a/src/libs/actions/Transaction.ts b/src/libs/actions/Transaction.ts index 574cb4311c7fc..5d3201047fd4f 100644 --- a/src/libs/actions/Transaction.ts +++ b/src/libs/actions/Transaction.ts @@ -717,8 +717,25 @@ function changeTransactionsReport( } const optimisticData: OnyxUpdate[] = []; - const failureData: OnyxUpdate[] = []; - const successData: OnyxUpdate[] = []; + const failureData: Array< + OnyxUpdate< + | typeof ONYXKEYS.COLLECTION.REPORT + | typeof ONYXKEYS.COLLECTION.REPORT_METADATA + | typeof ONYXKEYS.COLLECTION.REPORT_ACTIONS + | typeof ONYXKEYS.COLLECTION.TRANSACTION + | typeof ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS + | typeof ONYXKEYS.COLLECTION.NEXT_STEP + > + > = []; + const successData: Array< + OnyxUpdate< + | typeof ONYXKEYS.COLLECTION.REPORT + | typeof ONYXKEYS.COLLECTION.REPORT_METADATA + | typeof ONYXKEYS.COLLECTION.REPORT_ACTIONS + | typeof ONYXKEYS.COLLECTION.TRANSACTION + | typeof ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS + > + > = []; const existingSelfDMReportID = findSelfDMReportID(); let selfDMReport: Report | undefined; @@ -1075,9 +1092,9 @@ function changeTransactionsReport( failureData.push({ onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${oldIOUAction.childReportID}`, + // @ts-expect-error - will be solved in https://github.com/Expensify/App/issues/73830 value: { parentReportID: isUnreportedExpense ? selfDMReportID : oldReportID, - // @ts-expect-error - will be solved in https://github.com/Expensify/App/issues/73830 optimisticMoneyRequestReportActionID: oldIOUAction.reportActionID, policyID: allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${oldIOUAction.reportActionID}`]?.policyID, }, diff --git a/src/libs/actions/Travel.ts b/src/libs/actions/Travel.ts index 10740c069c24a..a135bb817b5e8 100644 --- a/src/libs/actions/Travel.ts +++ b/src/libs/actions/Travel.ts @@ -11,7 +11,7 @@ import type {Route} from '@src/ROUTES'; * Accept Spotnana terms and conditions to receive a proper token used for authenticating further actions */ function acceptSpotnanaTerms(domain?: string, policyID?: string) { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: 'merge', key: ONYXKEYS.NVP_TRAVEL_SETTINGS, @@ -29,7 +29,7 @@ function acceptSpotnanaTerms(domain?: string, policyID?: string) { }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: 'merge', key: ONYXKEYS.TRAVEL_PROVISIONING, @@ -48,7 +48,7 @@ function acceptSpotnanaTerms(domain?: string, policyID?: string) { }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: 'merge', key: ONYXKEYS.TRAVEL_PROVISIONING, @@ -68,12 +68,12 @@ function acceptSpotnanaTerms(domain?: string, policyID?: string) { } function requestTravelAccess() { - const optimisticData: OnyxUpdate[] = [ - // @ts-expect-error - will be solved in https://github.com/Expensify/App/issues/73830 + const optimisticData: Array> = [ { onyxMethod: 'merge', key: ONYXKEYS.NVP_TRAVEL_SETTINGS, value: { + // @ts-expect-error - will be solved in https://github.com/Expensify/App/issues/73830 lastTravelSignupRequestTime: Date.now(), }, }, diff --git a/src/libs/actions/UnreportedExpenses.tsx b/src/libs/actions/UnreportedExpenses.tsx index cf26795048904..f24ff0695561c 100644 --- a/src/libs/actions/UnreportedExpenses.tsx +++ b/src/libs/actions/UnreportedExpenses.tsx @@ -5,7 +5,7 @@ import {READ_COMMANDS} from '@libs/API/types'; import ONYXKEYS from '@src/ONYXKEYS'; function fetchUnreportedExpenses(offset: number) { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.IS_LOADING_UNREPORTED_TRANSACTIONS, @@ -13,7 +13,7 @@ function fetchUnreportedExpenses(offset: number) { }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.IS_LOADING_UNREPORTED_TRANSACTIONS, @@ -21,7 +21,7 @@ function fetchUnreportedExpenses(offset: number) { }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.IS_LOADING_UNREPORTED_TRANSACTIONS, diff --git a/src/libs/actions/User.ts b/src/libs/actions/User.ts index 39e7487c72a2f..fba3ecffe555c 100644 --- a/src/libs/actions/User.ts +++ b/src/libs/actions/User.ts @@ -97,14 +97,14 @@ function closeAccount(reason: string) { // Note: successData does not need to set isLoading to false because if the CloseAccount // command succeeds, a Pusher response will clear all Onyx data. - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.FORMS.CLOSE_ACCOUNT_FORM, value: {isLoading: true}, }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.FORMS.CLOSE_ACCOUNT_FORM, @@ -138,7 +138,7 @@ function resendValidateCode(login: string) { * @param contactMethod - the new contact method that the user is trying to verify */ function requestContactMethodValidateCode(contactMethod: string) { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.LOGIN_LIST, @@ -156,7 +156,7 @@ function requestContactMethodValidateCode(contactMethod: string) { }, }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.LOGIN_LIST, @@ -171,7 +171,7 @@ function requestContactMethodValidateCode(contactMethod: string) { }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.LOGIN_LIST, @@ -198,14 +198,14 @@ function requestContactMethodValidateCode(contactMethod: string) { * Sets whether the user account is subscribed to Expensify news */ function updateNewsletterSubscription(isSubscribed: boolean) { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.ACCOUNT, value: {isSubscribedToNewsletter: isSubscribed}, }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.ACCOUNT, @@ -229,7 +229,7 @@ function updateNewsletterSubscription(isSubscribed: boolean) { function deleteContactMethod(contactMethod: string, loginList: Record, backTo?: string) { const oldLoginData = loginList[contactMethod]; - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.LOGIN_LIST, @@ -244,7 +244,7 @@ function deleteContactMethod(contactMethod: string, loginList: Record> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.LOGIN_LIST, @@ -253,7 +253,7 @@ function deleteContactMethod(contactMethod: string, loginList: Record> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.LOGIN_LIST, @@ -363,7 +363,7 @@ function addPendingContactMethod(contactMethod: string) { * Adds a secondary login to a user's account */ function addNewContactMethod(contactMethod: string, validateCode = '') { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.LOGIN_LIST, @@ -383,7 +383,7 @@ function addNewContactMethod(contactMethod: string, validateCode = '') { value: {isLoading: true}, }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.PENDING_CONTACT_ACTION, @@ -402,7 +402,7 @@ function addNewContactMethod(contactMethod: string, validateCode = '') { value: {isLoading: false}, }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.ACCOUNT, @@ -424,7 +424,7 @@ function addNewContactMethod(contactMethod: string, validateCode = '') { * Requests a magic code to verify current user */ function requestValidateCodeAction() { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.VALIDATE_ACTION_CODE, @@ -440,7 +440,7 @@ function requestValidateCodeAction() { }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.VALIDATE_ACTION_CODE, @@ -457,7 +457,7 @@ function requestValidateCodeAction() { }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.VALIDATE_ACTION_CODE, @@ -487,7 +487,7 @@ function validateSecondaryLogin( formatPhoneNumber: LocaleContextProps['formatPhoneNumber'], shouldResetActionCode?: boolean, ) { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.LOGIN_LIST, @@ -959,7 +959,7 @@ function subscribeToUserEvents() { * Sync preferredSkinTone with Onyx and Server */ function updatePreferredSkinTone(skinTone: number) { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.SET, key: ONYXKEYS.PREFERRED_EMOJI_SKIN_TONE, @@ -979,7 +979,7 @@ function updatePreferredSkinTone(skinTone: number) { */ function updateChatPriorityMode(mode: ValueOf, automatic = false) { const autoSwitchedToFocusMode = mode === CONST.PRIORITY_MODE.GSD && automatic; - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.NVP_PRIORITY_MODE, @@ -1017,14 +1017,14 @@ function togglePlatformMute(platform: Platform, mutedPlatforms: Partial> = [ { onyxMethod: Onyx.METHOD.SET, key: ONYXKEYS.NVP_MUTED_PLATFORMS, value: newMutedPlatforms, }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.SET, key: ONYXKEYS.NVP_MUTED_PLATFORMS, @@ -1062,7 +1062,7 @@ function joinScreenShare(accessToken: string, roomName: string) { * @param period YYYYMM format */ function generateStatementPDF(period: string) { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.WALLET_STATEMENT, @@ -1071,7 +1071,7 @@ function generateStatementPDF(period: string) { }, }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.WALLET_STATEMENT, @@ -1080,7 +1080,7 @@ function generateStatementPDF(period: string) { }, }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.WALLET_STATEMENT, @@ -1104,7 +1104,9 @@ function generateStatementPDF(period: string) { */ function setContactMethodAsDefault(newDefaultContactMethod: string, formatPhoneNumber: LocaleContextProps['formatPhoneNumber'], backTo?: string) { const oldDefaultContactMethod = currentEmail; - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array< + OnyxUpdate + > = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.ACCOUNT, @@ -1144,7 +1146,7 @@ function setContactMethodAsDefault(newDefaultContactMethod: string, formatPhoneN }, }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.LOGIN_LIST, @@ -1157,7 +1159,9 @@ function setContactMethodAsDefault(newDefaultContactMethod: string, formatPhoneN }, }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array< + OnyxUpdate + > = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.ACCOUNT, @@ -1256,7 +1260,7 @@ function setContactMethodAsDefault(newDefaultContactMethod: string, formatPhoneN } function updateTheme(theme: ValueOf) { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.SET, key: ONYXKEYS.PREFERRED_THEME, @@ -1277,7 +1281,7 @@ function updateTheme(theme: ValueOf) { * Sets a custom status */ function updateCustomStatus(status: Status) { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.PERSONAL_DETAILS_LIST, @@ -1300,7 +1304,7 @@ function updateCustomStatus(status: Status) { * Clears the custom status */ function clearCustomStatus() { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.PERSONAL_DETAILS_LIST, @@ -1341,7 +1345,7 @@ function clearDraftCustomStatus() { } function dismissReferralBanner(type: ValueOf) { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.NVP_DISMISSED_REFERRAL_BANNERS, @@ -1408,7 +1412,7 @@ function setIsDebugModeEnabled(isDebugModeEnabled: boolean) { } function lockAccount() { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.ACCOUNT, @@ -1421,7 +1425,7 @@ function lockAccount() { }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.ACCOUNT, @@ -1434,7 +1438,7 @@ function lockAccount() { }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.ACCOUNT, @@ -1472,9 +1476,9 @@ type RespondToProactiveAppReviewParams = { */ function respondToProactiveAppReview(response: 'positive' | 'negative' | 'skip', currentProactiveAppReview: AppReview | null | undefined, message?: string, conciergeChatReportID?: string) { const params: RespondToProactiveAppReviewParams = {response}; - const optimisticData: OnyxUpdate[] = []; - const successData: OnyxUpdate[] = []; - const failureData: OnyxUpdate[] = []; + const optimisticData: Array> = []; + const successData: Array> = []; + const failureData: Array> = []; // Capture current values for failure data const originalResponse = currentProactiveAppReview?.response; diff --git a/src/libs/actions/VacationDelegate.ts b/src/libs/actions/VacationDelegate.ts index 32cdc7953610b..320e7edbf4e57 100644 --- a/src/libs/actions/VacationDelegate.ts +++ b/src/libs/actions/VacationDelegate.ts @@ -10,7 +10,7 @@ import type {VacationDelegate} from '@src/types/onyx'; import {isEmptyObject} from '@src/types/utils/EmptyObject'; function setVacationDelegate(creator: string, delegate: string, shouldOverridePolicyDiffWarning = false, currentDelegate?: string) { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.NVP_PRIVATE_VACATION_DELEGATE, @@ -24,7 +24,7 @@ function setVacationDelegate(creator: string, delegate: string, shouldOverridePo }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.NVP_PRIVATE_VACATION_DELEGATE, @@ -36,12 +36,12 @@ function setVacationDelegate(creator: string, delegate: string, shouldOverridePo }, ]; - const failureData: OnyxUpdate[] = [ - // @ts-expect-error - will be solved in https://github.com/Expensify/App/issues/73830 + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.NVP_PRIVATE_VACATION_DELEGATE, value: { + // @ts-expect-error - will be solved in https://github.com/Expensify/App/issues/73830 errors: ErrorUtils.getMicroSecondTranslationErrorWithTranslationKey('statusPage.vacationDelegateError'), }, }, @@ -64,7 +64,7 @@ function deleteVacationDelegate(vacationDelegate?: VacationDelegate) { } const {creator, delegate} = vacationDelegate; - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.NVP_PRIVATE_VACATION_DELEGATE, @@ -77,7 +77,7 @@ function deleteVacationDelegate(vacationDelegate?: VacationDelegate) { }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.NVP_PRIVATE_VACATION_DELEGATE, @@ -88,14 +88,14 @@ function deleteVacationDelegate(vacationDelegate?: VacationDelegate) { }, ]; - const failureData: OnyxUpdate[] = [ - // @ts-expect-error - will be solved in https://github.com/Expensify/App/issues/73830 + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.NVP_PRIVATE_VACATION_DELEGATE, value: { creator, delegate, + // @ts-expect-error - will be solved in https://github.com/Expensify/App/issues/73830 errors: ErrorUtils.getMicroSecondTranslationErrorWithTranslationKey('statusPage.vacationDelegateError'), }, }, diff --git a/src/libs/actions/Wallet.ts b/src/libs/actions/Wallet.ts index e1fb3356e92f5..1504485c609e5 100644 --- a/src/libs/actions/Wallet.ts +++ b/src/libs/actions/Wallet.ts @@ -23,7 +23,7 @@ type WalletQuestionAnswer = { * identity check. Note: This happens in Web-Secure when we call Activate_Wallet during the OnfidoStep. */ function openOnfidoFlow() { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { // Use Onyx.set() since we are resetting the Onfido flow completely. onyxMethod: Onyx.METHOD.SET, @@ -34,7 +34,7 @@ function openOnfidoFlow() { }, ]; - const finallyData: OnyxUpdate[] = [ + const finallyData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.WALLET_ONFIDO, @@ -62,7 +62,7 @@ function setKYCWallSource(source?: ValueOf, chatRe * Validates a user's provided details against a series of checks */ function updatePersonalDetails(personalDetails: UpdatePersonalDetailsForWalletParams) { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.FORMS.WALLET_ADDITIONAL_DETAILS, @@ -74,7 +74,7 @@ function updatePersonalDetails(personalDetails: UpdatePersonalDetailsForWalletPa }, ]; - const finallyData: OnyxUpdate[] = [ + const finallyData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.FORMS.WALLET_ADDITIONAL_DETAILS, @@ -97,7 +97,7 @@ function updatePersonalDetails(personalDetails: UpdatePersonalDetailsForWalletPa * API request to fetch the userWallet after we call VerifyIdentity */ function verifyIdentity(parameters: VerifyIdentityParams) { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.WALLET_ONFIDO, @@ -116,7 +116,7 @@ function verifyIdentity(parameters: VerifyIdentityParams) { }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.WALLET_ONFIDO, @@ -127,7 +127,7 @@ function verifyIdentity(parameters: VerifyIdentityParams) { }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.WALLET_ONFIDO, @@ -150,7 +150,7 @@ function verifyIdentity(parameters: VerifyIdentityParams) { * @param parameters.chatReportID When accepting the terms of wallet to pay an IOU, indicates the parent chat ID of the IOU */ function acceptWalletTerms(parameters: AcceptWalletTermsParams) { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.WALLET_TERMS, @@ -160,7 +160,7 @@ function acceptWalletTerms(parameters: AcceptWalletTermsParams) { }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.WALLET_TERMS, @@ -171,7 +171,7 @@ function acceptWalletTerms(parameters: AcceptWalletTermsParams) { }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.USER_WALLET, @@ -215,7 +215,7 @@ function updateCurrentStep(currentStep: ValueOf | null function answerQuestionsForWallet(answers: WalletQuestionAnswer[], idNumber: string) { const idologyAnswers = JSON.stringify(answers); - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.FORMS.WALLET_ADDITIONAL_DETAILS, @@ -225,7 +225,7 @@ function answerQuestionsForWallet(answers: WalletQuestionAnswer[], idNumber: str }, ]; - const finallyData: OnyxUpdate[] = [ + const finallyData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.FORMS.WALLET_ADDITIONAL_DETAILS, diff --git a/src/libs/actions/Welcome/index.ts b/src/libs/actions/Welcome/index.ts index c3c5ada15d101..1b74d7ed11ef9 100644 --- a/src/libs/actions/Welcome/index.ts +++ b/src/libs/actions/Welcome/index.ts @@ -161,7 +161,7 @@ function completeHybridAppOnboarding() { return; } - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.NVP_TRY_NEW_DOT, @@ -233,7 +233,7 @@ function setSelfTourViewed(shouldUpdateOnyxDataOnlyLocally = false) { return; } - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.NVP_ONBOARDING, diff --git a/src/libs/actions/Workflow.ts b/src/libs/actions/Workflow.ts index 52f3cc015ec82..5e54358204221 100644 --- a/src/libs/actions/Workflow.ts +++ b/src/libs/actions/Workflow.ts @@ -41,7 +41,7 @@ function createApprovalWorkflow(approvalWorkflow: ApprovalWorkflow, policy: Onyx return; } - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.SET, key: ONYXKEYS.APPROVAL_WORKFLOW, @@ -57,7 +57,7 @@ function createApprovalWorkflow(approvalWorkflow: ApprovalWorkflow, policy: Onyx }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policy.id}`, @@ -68,7 +68,7 @@ function createApprovalWorkflow(approvalWorkflow: ApprovalWorkflow, policy: Onyx }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policy.id}`, @@ -104,7 +104,7 @@ function updateApprovalWorkflow(approvalWorkflow: ApprovalWorkflow, membersToRem return; } - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.SET, key: ONYXKEYS.APPROVAL_WORKFLOW, @@ -120,7 +120,7 @@ function updateApprovalWorkflow(approvalWorkflow: ApprovalWorkflow, membersToRem }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policy.id}`, @@ -132,7 +132,7 @@ function updateApprovalWorkflow(approvalWorkflow: ApprovalWorkflow, membersToRem }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policy.id}`, @@ -163,7 +163,7 @@ function removeApprovalWorkflow(approvalWorkflow: ApprovalWorkflow, policy: Onyx // If there is more than one workflow, we need to keep the advanced approval mode (first workflow is the default) const hasMoreThanOneWorkflow = Object.values(updatedEmployeeList).some((employee) => !!employee.submitsTo && employee.submitsTo !== defaultApprover); - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.SET, key: ONYXKEYS.APPROVAL_WORKFLOW, @@ -179,7 +179,7 @@ function removeApprovalWorkflow(approvalWorkflow: ApprovalWorkflow, policy: Onyx }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policy.id}`, @@ -190,7 +190,7 @@ function removeApprovalWorkflow(approvalWorkflow: ApprovalWorkflow, policy: Onyx }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policy.id}`, diff --git a/src/libs/actions/connections/NetSuiteCommands.ts b/src/libs/actions/connections/NetSuiteCommands.ts index b6e8c6976845b..91bb986ca4116 100644 --- a/src/libs/actions/connections/NetSuiteCommands.ts +++ b/src/libs/actions/connections/NetSuiteCommands.ts @@ -19,7 +19,7 @@ type SubsidiaryParam = { }; function connectPolicyToNetSuite(policyID: string, credentials: Omit) { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY_CONNECTION_SYNC_PROGRESS}${policyID}`, @@ -76,7 +76,7 @@ function updateNetSuiteOnyxData> = [ // @ts-expect-error - will be solved in https://github.com/Expensify/App/issues/73830 { onyxMethod: Onyx.METHOD.MERGE, @@ -98,7 +98,7 @@ function updateNetSuiteOnyxData> = [ // @ts-expect-error - will be solved in https://github.com/Expensify/App/issues/73830 { onyxMethod: Onyx.METHOD.MERGE, @@ -120,7 +120,7 @@ function updateNetSuiteOnyxData> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -156,7 +156,7 @@ function updateNetSuiteSyncOptionsOnyxData> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -190,7 +190,7 @@ function updateNetSuiteSyncOptionsOnyxData> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -212,7 +212,7 @@ function updateNetSuiteSyncOptionsOnyxData> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -777,7 +777,7 @@ function updateNetSuiteAutoSync(policyID: string | undefined, value: boolean) { if (!policyID) { return; } - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -801,7 +801,7 @@ function updateNetSuiteAutoSync(policyID: string | undefined, value: boolean) { }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -825,7 +825,7 @@ function updateNetSuiteAutoSync(policyID: string | undefined, value: boolean) { }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, diff --git a/src/libs/actions/connections/QuickbooksDesktop.ts b/src/libs/actions/connections/QuickbooksDesktop.ts index c6f50ddd85333..ab3aa5f09bb88 100644 --- a/src/libs/actions/connections/QuickbooksDesktop.ts +++ b/src/libs/actions/connections/QuickbooksDesktop.ts @@ -19,7 +19,7 @@ function buildOnyxDataForMultipleQuickbooksExportConfigurations, ) { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -37,7 +37,7 @@ function buildOnyxDataForMultipleQuickbooksExportConfigurations> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -57,7 +57,7 @@ function buildOnyxDataForMultipleQuickbooksExportConfigurations> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -89,7 +89,7 @@ function buildOnyxDataForQuickbooksExportConfiguration> = [ // @ts-expect-error - will be solved in https://github.com/Expensify/App/issues/73830 { onyxMethod: Onyx.METHOD.MERGE, @@ -115,7 +115,7 @@ function buildOnyxDataForQuickbooksExportConfiguration> = [ // @ts-expect-error - will be solved in https://github.com/Expensify/App/issues/73830 { onyxMethod: Onyx.METHOD.MERGE, @@ -141,7 +141,7 @@ function buildOnyxDataForQuickbooksExportConfiguration> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -177,7 +177,7 @@ function buildOnyxDataForQuickbooksDesktopMappingsConfiguration, oldSettingValue?: Partial, ) { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -201,7 +201,7 @@ function buildOnyxDataForQuickbooksDesktopMappingsConfiguration> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -225,7 +225,7 @@ function buildOnyxDataForQuickbooksDesktopMappingsConfiguration> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -258,7 +258,7 @@ function buildOnyxDataForQuickbooksConfiguration, oldSettingValue?: Partial, ) { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -280,7 +280,7 @@ function buildOnyxDataForQuickbooksConfiguration> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -302,7 +302,7 @@ function buildOnyxDataForQuickbooksConfiguration> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, diff --git a/src/libs/actions/connections/QuickbooksOnline.ts b/src/libs/actions/connections/QuickbooksOnline.ts index e4160c589ccc6..1296e8862fe1e 100644 --- a/src/libs/actions/connections/QuickbooksOnline.ts +++ b/src/libs/actions/connections/QuickbooksOnline.ts @@ -35,7 +35,7 @@ function buildOnyxDataForMultipleQuickbooksConfigurations> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -53,7 +53,7 @@ function buildOnyxDataForMultipleQuickbooksConfigurations> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -73,7 +73,7 @@ function buildOnyxDataForMultipleQuickbooksConfigurations> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -105,7 +105,7 @@ function buildOnyxDataForQuickbooksConfiguration> = [ // @ts-expect-error - will be solved in https://github.com/Expensify/App/issues/73830 { onyxMethod: Onyx.METHOD.MERGE, @@ -129,7 +129,7 @@ function buildOnyxDataForQuickbooksConfiguration> = [ // @ts-expect-error - will be solved in https://github.com/Expensify/App/issues/73830 { onyxMethod: Onyx.METHOD.MERGE, @@ -153,7 +153,7 @@ function buildOnyxDataForQuickbooksConfiguration> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, diff --git a/src/libs/actions/connections/SageIntacct.ts b/src/libs/actions/connections/SageIntacct.ts index 6a07eeb564bac..b135b5c8ad1f9 100644 --- a/src/libs/actions/connections/SageIntacct.ts +++ b/src/libs/actions/connections/SageIntacct.ts @@ -39,7 +39,7 @@ function prepareOnyxDataForMappingUpdate( mappingValue: boolean | SageIntacctMappingValue, oldMappingValue?: boolean | SageIntacctMappingValue, ) { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -63,7 +63,7 @@ function prepareOnyxDataForMappingUpdate( }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -87,7 +87,7 @@ function prepareOnyxDataForMappingUpdate( }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -175,7 +175,7 @@ function UpdateSageIntacctTaxSolutionID(policyID: string | undefined, taxSolutio if (!policyID) { return; } - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -199,7 +199,7 @@ function UpdateSageIntacctTaxSolutionID(policyID: string | undefined, taxSolutio }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -223,7 +223,7 @@ function UpdateSageIntacctTaxSolutionID(policyID: string | undefined, taxSolutio }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -251,7 +251,7 @@ function updateSageIntacctSyncTaxConfiguration(policyID: string | undefined, ena if (!policyID) { return; } - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -275,7 +275,7 @@ function updateSageIntacctSyncTaxConfiguration(policyID: string | undefined, ena }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -299,7 +299,7 @@ function updateSageIntacctSyncTaxConfiguration(policyID: string | undefined, ena }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -330,7 +330,7 @@ function prepareOnyxDataForUserDimensionUpdate( oldDimensionName: string, pendingAction: OnyxCommon.PendingAction, ) { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -352,7 +352,7 @@ function prepareOnyxDataForUserDimensionUpdate( const pendingActionAfterFailure = pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD ? pendingAction : null; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -374,7 +374,7 @@ function prepareOnyxDataForUserDimensionUpdate( }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -447,7 +447,7 @@ function prepareOnyxDataForExportUpdate(policyID: string, settingName: keyof Sag const exporterOptimisticData = settingName === CONST.SAGE_INTACCT_CONFIG.EXPORTER ? {exporter: settingValue} : {}; const exporterErrorData = settingName === CONST.SAGE_INTACCT_CONFIG.EXPORTER ? {exporter: oldSettingValue} : {}; - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -472,7 +472,7 @@ function prepareOnyxDataForExportUpdate(policyID: string, settingName: keyof Sag }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -497,7 +497,7 @@ function prepareOnyxDataForExportUpdate(policyID: string, settingName: keyof Sag }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -638,7 +638,7 @@ function removeSageIntacctUserDimensionsByName(dimensions: SageIntacctDimension[ } function prepareOnyxDataForConfigUpdate(policyID: string, settingName: keyof SageIntacctConnectionsConfig, settingValue: string | boolean | null, oldSettingValue?: string | boolean | null) { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -660,7 +660,7 @@ function prepareOnyxDataForConfigUpdate(policyID: string, settingName: keyof Sag }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -682,7 +682,7 @@ function prepareOnyxDataForConfigUpdate(policyID: string, settingName: keyof Sag }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -707,7 +707,7 @@ function prepareOnyxDataForConfigUpdate(policyID: string, settingName: keyof Sag } function prepareOnyxDataForSyncUpdate(policyID: string, settingName: keyof Connections['intacct']['config']['sync'], settingValue: string | boolean, oldSettingValue?: string | boolean) { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -731,7 +731,7 @@ function prepareOnyxDataForSyncUpdate(policyID: string, settingName: keyof Conne }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -755,7 +755,7 @@ function prepareOnyxDataForSyncUpdate(policyID: string, settingName: keyof Conne }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -780,7 +780,7 @@ function prepareOnyxDataForSyncUpdate(policyID: string, settingName: keyof Conne } function prepareOnyxDataForAutoSyncUpdate(policyID: string, settingName: keyof Connections['intacct']['config']['autoSync'], settingValue: boolean) { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -804,7 +804,7 @@ function prepareOnyxDataForAutoSyncUpdate(policyID: string, settingName: keyof C }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -828,7 +828,7 @@ function prepareOnyxDataForAutoSyncUpdate(policyID: string, settingName: keyof C }, ]; - const successData: OnyxUpdate[] = [ + const successData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, diff --git a/src/libs/actions/connections/Xero.ts b/src/libs/actions/connections/Xero.ts index ff6e46e129408..78e943a4a72af 100644 --- a/src/libs/actions/connections/Xero.ts +++ b/src/libs/actions/connections/Xero.ts @@ -131,7 +131,7 @@ function prepareXeroOptimisticData, oldSettingValue?: Partial | null, ) { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -149,7 +149,7 @@ function prepareXeroOptimisticData> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -167,7 +167,7 @@ function prepareXeroOptimisticData> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -193,7 +193,7 @@ function prepareXeroExportOptimisticData, oldSettingValue?: Partial | null, ) { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -213,7 +213,7 @@ function prepareXeroExportOptimisticData> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -233,7 +233,7 @@ function prepareXeroExportOptimisticData> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -259,7 +259,7 @@ function prepareXeroSyncOptimisticData, oldSettingValue?: Partial | null, ) { - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -279,7 +279,7 @@ function prepareXeroSyncOptimisticData> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -299,7 +299,7 @@ function prepareXeroSyncOptimisticData> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, diff --git a/src/libs/actions/connections/index.ts b/src/libs/actions/connections/index.ts index 5aae863c6e538..8d123a0de3163 100644 --- a/src/libs/actions/connections/index.ts +++ b/src/libs/actions/connections/index.ts @@ -18,7 +18,14 @@ function removePolicyConnection(policy: Policy, connectionName: PolicyConnection const policyID = policy.id; const workspaceAccountID = policy?.workspaceAccountID ?? CONST.DEFAULT_NUMBER_ID; - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array< + OnyxUpdate< + | typeof ONYXKEYS.COLLECTION.POLICY + | typeof ONYXKEYS.COLLECTION.POLICY_CONNECTION_SYNC_PROGRESS + | typeof ONYXKEYS.COLLECTION.EXPENSIFY_CARD_CONTINUOUS_RECONCILIATION_CONNECTION + | typeof ONYXKEYS.COLLECTION.EXPENSIFY_CARD_USE_CONTINUOUS_RECONCILIATION + > + > = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -45,8 +52,8 @@ function removePolicyConnection(policy: Policy, connectionName: PolicyConnection }, ]; - const successData: OnyxUpdate[] = []; - const failureData: OnyxUpdate[] = []; + const successData: Array> = []; + const failureData: Array> = []; const supportedConnections: PolicyConnectionName[] = [CONST.POLICY.CONNECTIONS.NAME.QBO, CONST.POLICY.CONNECTIONS.NAME.XERO]; if (PolicyUtils.isCollectPolicy(policy) && supportedConnections.includes(connectionName)) { @@ -135,7 +142,7 @@ function syncConnection(policy: Policy | undefined, connectionName: PolicyConnec if (!syncConnectionData) { return; } - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY_CONNECTION_SYNC_PROGRESS}${policyID}`, @@ -147,7 +154,7 @@ function syncConnection(policy: Policy | undefined, connectionName: PolicyConnec }, ]; - const failureData: OnyxUpdate[] = [ + const failureData: Array> = [ { onyxMethod: Onyx.METHOD.SET, key: `${ONYXKEYS.COLLECTION.POLICY_CONNECTION_SYNC_PROGRESS}${policyID}`, @@ -179,7 +186,7 @@ function updateManyPolicyConnectionConfigs> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -197,7 +204,7 @@ function updateManyPolicyConnectionConfigs> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -217,7 +224,7 @@ function updateManyPolicyConnectionConfigs> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -301,7 +308,7 @@ function copyExistingPolicyConnection(connectedPolicyID: string, targetPolicyID: stageInProgress = null; } - const optimisticData: OnyxUpdate[] = [ + const optimisticData: Array> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY_CONNECTION_SYNC_PROGRESS}${targetPolicyID}`, diff --git a/tests/actions/QueuedOnyxUpdatesTest.ts b/tests/actions/QueuedOnyxUpdatesTest.ts index b0f5a2b384473..d9959d31f6d4c 100644 --- a/tests/actions/QueuedOnyxUpdatesTest.ts +++ b/tests/actions/QueuedOnyxUpdatesTest.ts @@ -5,7 +5,19 @@ import type {OnyxKey} from '@src/ONYXKEYS'; import ONYXKEYS from '@src/ONYXKEYS'; import waitForBatchedUpdates from '../utils/waitForBatchedUpdates'; -const queuedOnyxUpdates: OnyxUpdate[] = [ +const queuedOnyxUpdates: Array< + OnyxUpdate< + | typeof ONYXKEYS.NVP_TRY_FOCUS_MODE + | typeof ONYXKEYS.PREFERRED_THEME + | typeof ONYXKEYS.NVP_PREFERRED_LOCALE + | typeof ONYXKEYS.SESSION + | typeof ONYXKEYS.IS_LOADING_APP + | typeof ONYXKEYS.CREDENTIALS + | typeof ONYXKEYS.IS_SIDEBAR_LOADED + | typeof ONYXKEYS.COLLECTION.REPORT + | typeof ONYXKEYS.COLLECTION.REPORT_ACTIONS + > +> = [ {key: ONYXKEYS.NVP_TRY_FOCUS_MODE, value: true, onyxMethod: 'merge'}, {key: ONYXKEYS.PREFERRED_THEME, value: 'system', onyxMethod: 'merge'}, {key: ONYXKEYS.NVP_PREFERRED_LOCALE, value: 'en', onyxMethod: 'merge'},