Skip to content

Commit f873c0e

Browse files
authored
Merge pull request #61597 from Expensify/aldo_remove-cast
Improve type handling / remove casts
2 parents b74a840 + 042e7fd commit f873c0e

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/libs/actions/Transaction.ts

+10-6
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import {
2222
import {getAmount, getTransaction, waypointHasValidAddress} from '@libs/TransactionUtils';
2323
import CONST from '@src/CONST';
2424
import ONYXKEYS from '@src/ONYXKEYS';
25-
import type {PersonalDetails, RecentWaypoint, Report, ReportAction, ReportActions, ReviewDuplicates, Transaction, TransactionViolation, TransactionViolations} from '@src/types/onyx';
25+
import type {PersonalDetails, RecentWaypoint, Report, ReportAction, ReviewDuplicates, Transaction, TransactionViolation, TransactionViolations} from '@src/types/onyx';
2626
import type {OriginalMessageModifiedExpense} from '@src/types/onyx/OriginalMessage';
2727
import type {OnyxData} from '@src/types/onyx/Request';
2828
import type {WaypointCollection} from '@src/types/onyx/Transaction';
@@ -279,11 +279,15 @@ function getOnyxDataForRouteRequest(transactionID: string, transactionState: Tra
279279
* @returns The sanitized collection of waypoints.
280280
*/
281281
function sanitizeRecentWaypoints(waypoints: WaypointCollection): WaypointCollection {
282-
return Object.entries(waypoints).reduce((acc, [key, waypoint]) => {
283-
const {pendingAction, ...rest} = waypoint as RecentWaypoint;
284-
acc[key] = rest;
282+
return Object.entries(waypoints).reduce((acc: WaypointCollection, [key, waypoint]) => {
283+
if ('pendingAction' in waypoint) {
284+
const {pendingAction, ...rest} = waypoint;
285+
acc[key] = rest;
286+
} else {
287+
acc[key] = waypoint;
288+
}
285289
return acc;
286-
}, {} as WaypointCollection);
290+
}, {});
287291
}
288292

289293
/**
@@ -518,7 +522,7 @@ function markAsCash(transactionID: string | undefined, transactionThreadReportID
518522
{
519523
onyxMethod: Onyx.METHOD.MERGE,
520524
key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${transactionThreadReportID}`,
521-
value: optimisticReportActions as ReportActions,
525+
value: optimisticReportActions,
522526
},
523527
],
524528
failureData: [

0 commit comments

Comments
 (0)