From 0a276e2ad95a4c99164d208ec927966f83b54118 Mon Sep 17 00:00:00 2001 From: Eric Jinks <3147296+Jinksi@users.noreply.github.com> Date: Fri, 20 Dec 2024 12:34:50 +1000 Subject: [PATCH 1/2] Add type assertion for disputes CSV export response Add TypeScript type assertion to `apiFetch` call in disputes CSV export to: - Ensure type safety for `exported_disputes` response property - Add JSDoc documentation for the exported disputes count - Fix TypeScript error "Property 'exported_disputes' does not exist on type 'unknown'" --- client/disputes/index.tsx | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/client/disputes/index.tsx b/client/disputes/index.tsx index cdb85131f5d..dd7104b5930 100644 --- a/client/disputes/index.tsx +++ b/client/disputes/index.tsx @@ -399,22 +399,25 @@ export const DisputesList = (): JSX.Element => { window.confirm( confirmMessage ) ) { try { - const { exported_disputes: exportedDisputes } = await apiFetch( - { - path: getDisputesCSV( { - userEmail, - locale, - dateAfter, - dateBefore, - dateBetween, - match, - filter, - statusIs, - statusIsNot, - } ), - method: 'POST', - } - ); + const { + exported_disputes: exportedDisputes, + } = await apiFetch< { + /** The total number of disputes that will be exported in the CSV. */ + exported_disputes: number; + } >( { + path: getDisputesCSV( { + userEmail, + locale, + dateAfter, + dateBefore, + dateBetween, + match, + filter, + statusIs, + statusIsNot, + } ), + method: 'POST', + } ); createNotice( 'success', From 9f8a2551edc190cdab6bf7922fd98bf7691c1231 Mon Sep 17 00:00:00 2001 From: Eric Jinks <3147296+Jinksi@users.noreply.github.com> Date: Fri, 20 Dec 2024 12:35:53 +1000 Subject: [PATCH 2/2] Add changelog entry --- .../fix-10007-disputes-csv-export-response-type-assertion | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 changelog/fix-10007-disputes-csv-export-response-type-assertion diff --git a/changelog/fix-10007-disputes-csv-export-response-type-assertion b/changelog/fix-10007-disputes-csv-export-response-type-assertion new file mode 100644 index 00000000000..b578456ece2 --- /dev/null +++ b/changelog/fix-10007-disputes-csv-export-response-type-assertion @@ -0,0 +1,4 @@ +Significance: patch +Type: dev + +Add type assertion for disputes CSV export response to ensure type safety and fix TypeScript error