diff options
author | Sebastian <sebasjm@gmail.com> | 2024-07-11 12:06:20 -0300 |
---|---|---|
committer | Sebastian <sebasjm@gmail.com> | 2024-07-11 14:04:32 -0300 |
commit | 2609c7359356f1e991e41eceb7221c424d53bd1b (patch) | |
tree | 637a4fca269bce8e6b89e07f1fd6f1674e293da0 | |
parent | c9c6425f9fe3e8d7beb1f6455906812000a42d4a (diff) | |
download | wallet-core-2609c7359356f1e991e41eceb7221c424d53bd1b.tar.xz |
type guard: promise catch wont use any type
24 files changed, 86 insertions, 22 deletions
diff --git a/packages/bank-ui/src/type-override.d.ts b/packages/bank-ui/src/type-override.d.ts new file mode 100644 index 000000000..d820aff57 --- /dev/null +++ b/packages/bank-ui/src/type-override.d.ts @@ -0,0 +1,32 @@ +/* + This file is part of GNU Taler + (C) 2021-2024 Taler Systems S.A. + + GNU Taler is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + +/** + * define unkown type of catch function + */ +interface Promise<T> { + /** + * Attaches a callback for only the rejection of the Promise. + * @param onrejected The callback to execute when the Promise is rejected. + * @returns A Promise for the completion of the callback. + */ + catch<TResult = never>( + onrejected?: + | ((reason: unknown) => TResult | PromiseLike<TResult>) + | undefined + | null, + ): Promise<T | TResult>; +} diff --git a/packages/bank-ui/src/utils.ts b/packages/bank-ui/src/utils.ts index 2cc502416..64413b4d6 100644 --- a/packages/bank-ui/src/utils.ts +++ b/packages/bank-ui/src/utils.ts @@ -134,7 +134,7 @@ export async function withRuntimeErrorHandling<T>( ): Promise<void> { try { await cb(); - } catch (error: unknown) { + } catch (error) { if (error instanceof TalerError) { notify(buildRequestErrorMessage(i18n, error)); } else { diff --git a/packages/merchant-backoffice-ui/src/paths/instance/accounts/create/index.tsx b/packages/merchant-backoffice-ui/src/paths/instance/accounts/create/index.tsx index a1d5ecdad..ac48e65ea 100644 --- a/packages/merchant-backoffice-ui/src/paths/instance/accounts/create/index.tsx +++ b/packages/merchant-backoffice-ui/src/paths/instance/accounts/create/index.tsx @@ -72,7 +72,7 @@ export default function CreateValidator({ onConfirm, onBack }: Props): VNode { } onConfirm(); }) - .catch((error: unknown) => { + .catch((error) => { setNotif({ message: i18n.str`Could not create account`, type: "ERROR", diff --git a/packages/merchant-backoffice-ui/src/paths/instance/accounts/list/index.tsx b/packages/merchant-backoffice-ui/src/paths/instance/accounts/list/index.tsx index 836e5f2b4..2bb1144f5 100644 --- a/packages/merchant-backoffice-ui/src/paths/instance/accounts/list/index.tsx +++ b/packages/merchant-backoffice-ui/src/paths/instance/accounts/list/index.tsx @@ -106,7 +106,7 @@ export default function ListOtpDevices({ onCreate, onSelect }: Props): VNode { }); } }) - .catch((error: unknown) => + .catch((error) => setNotif({ message: i18n.str`Could not delete the bank account`, type: "ERROR", diff --git a/packages/merchant-backoffice-ui/src/paths/instance/accounts/update/index.tsx b/packages/merchant-backoffice-ui/src/paths/instance/accounts/update/index.tsx index b09b8de9e..aca8aeb8e 100644 --- a/packages/merchant-backoffice-ui/src/paths/instance/accounts/update/index.tsx +++ b/packages/merchant-backoffice-ui/src/paths/instance/accounts/update/index.tsx @@ -95,7 +95,7 @@ export default function UpdateValidator({ } onConfirm(); }) - .catch((error: unknown) => { + .catch((error) => { setNotif({ message: i18n.str`Could not update account`, type: "ERROR", diff --git a/packages/merchant-backoffice-ui/src/paths/instance/orders/create/index.tsx b/packages/merchant-backoffice-ui/src/paths/instance/orders/create/index.tsx index ca7b51c68..147c9e99c 100644 --- a/packages/merchant-backoffice-ui/src/paths/instance/orders/create/index.tsx +++ b/packages/merchant-backoffice-ui/src/paths/instance/orders/create/index.tsx @@ -112,7 +112,7 @@ export default function OrderCreate({ onConfirm, onBack }: Props): VNode { }); } }) - .catch((error: unknown) => { + .catch((error) => { setNotif({ message: i18n.str`Could not create order`, type: "ERROR", diff --git a/packages/merchant-backoffice-ui/src/paths/instance/orders/details/index.tsx b/packages/merchant-backoffice-ui/src/paths/instance/orders/details/index.tsx index 21383293e..7d5acd07f 100644 --- a/packages/merchant-backoffice-ui/src/paths/instance/orders/details/index.tsx +++ b/packages/merchant-backoffice-ui/src/paths/instance/orders/details/index.tsx @@ -96,7 +96,7 @@ export default function Update({ oid, onBack }: Props): VNode { }); } }) - .catch((error: unknown) => + .catch((error) => setNotif({ message: i18n.str`Could not create the refund`, type: "ERROR", diff --git a/packages/merchant-backoffice-ui/src/paths/instance/orders/list/index.tsx b/packages/merchant-backoffice-ui/src/paths/instance/orders/list/index.tsx index b3d52e226..3d1892b47 100644 --- a/packages/merchant-backoffice-ui/src/paths/instance/orders/list/index.tsx +++ b/packages/merchant-backoffice-ui/src/paths/instance/orders/list/index.tsx @@ -171,7 +171,7 @@ export default function OrderList({ onCreate, onSelect }: Props): VNode { }); } }) - .catch((error: unknown) => + .catch((error) => setNotif({ message: i18n.str`Could not create the refund`, type: "ERROR", diff --git a/packages/merchant-backoffice-ui/src/paths/instance/otp_devices/create/index.tsx b/packages/merchant-backoffice-ui/src/paths/instance/otp_devices/create/index.tsx index f25f0f842..adb417a09 100644 --- a/packages/merchant-backoffice-ui/src/paths/instance/otp_devices/create/index.tsx +++ b/packages/merchant-backoffice-ui/src/paths/instance/otp_devices/create/index.tsx @@ -69,7 +69,7 @@ export default function CreateValidator({ onConfirm, onBack }: Props): VNode { }); } }) - .catch((error: unknown) => { + .catch((error) => { setNotif({ message: i18n.str`Could not add device`, type: "ERROR", diff --git a/packages/merchant-backoffice-ui/src/paths/instance/otp_devices/list/index.tsx b/packages/merchant-backoffice-ui/src/paths/instance/otp_devices/list/index.tsx index 97493321d..d6f2bfe4d 100644 --- a/packages/merchant-backoffice-ui/src/paths/instance/otp_devices/list/index.tsx +++ b/packages/merchant-backoffice-ui/src/paths/instance/otp_devices/list/index.tsx @@ -98,7 +98,7 @@ export default function ListOtpDevices({ onCreate, onSelect }: Props): VNode { }); } }) - .catch((error: unknown) => + .catch((error) => setNotif({ message: i18n.str`Could not delete the device`, type: "ERROR", diff --git a/packages/merchant-backoffice-ui/src/paths/instance/otp_devices/update/index.tsx b/packages/merchant-backoffice-ui/src/paths/instance/otp_devices/update/index.tsx index d54022c03..8f9997cfb 100644 --- a/packages/merchant-backoffice-ui/src/paths/instance/otp_devices/update/index.tsx +++ b/packages/merchant-backoffice-ui/src/paths/instance/otp_devices/update/index.tsx @@ -133,7 +133,7 @@ export default function UpdateValidator({ } } }) - .catch((error: unknown) => { + .catch((error) => { setNotif({ message: i18n.str`Could not update template`, type: "ERROR", diff --git a/packages/merchant-backoffice-ui/src/paths/instance/products/create/index.tsx b/packages/merchant-backoffice-ui/src/paths/instance/products/create/index.tsx index 92aebeda8..5352fd792 100644 --- a/packages/merchant-backoffice-ui/src/paths/instance/products/create/index.tsx +++ b/packages/merchant-backoffice-ui/src/paths/instance/products/create/index.tsx @@ -61,7 +61,7 @@ export default function CreateProduct({ onConfirm, onBack }: Props): VNode { }); } }) - .catch((error: unknown) => { + .catch((error) => { setNotif({ message: i18n.str`Could not create product`, type: "ERROR", diff --git a/packages/merchant-backoffice-ui/src/paths/instance/products/update/index.tsx b/packages/merchant-backoffice-ui/src/paths/instance/products/update/index.tsx index 0701de405..06e140680 100644 --- a/packages/merchant-backoffice-ui/src/paths/instance/products/update/index.tsx +++ b/packages/merchant-backoffice-ui/src/paths/instance/products/update/index.tsx @@ -94,7 +94,7 @@ export default function UpdateProduct({ } }) - .catch((error: unknown) => { + .catch((error) => { setNotif({ message: i18n.str`Could not update product`, type: "ERROR", diff --git a/packages/merchant-backoffice-ui/src/paths/instance/templates/create/index.tsx b/packages/merchant-backoffice-ui/src/paths/instance/templates/create/index.tsx index a6a8595de..cc40591d4 100644 --- a/packages/merchant-backoffice-ui/src/paths/instance/templates/create/index.tsx +++ b/packages/merchant-backoffice-ui/src/paths/instance/templates/create/index.tsx @@ -61,7 +61,7 @@ export default function CreateTemplate({ onConfirm, onBack }: Props): VNode { }); } }) - .catch((error: unknown) => { + .catch((error) => { setNotif({ message: i18n.str`Could not create template`, type: "ERROR", diff --git a/packages/merchant-backoffice-ui/src/paths/instance/templates/update/index.tsx b/packages/merchant-backoffice-ui/src/paths/instance/templates/update/index.tsx index 45b9c0c7c..a42a40c63 100644 --- a/packages/merchant-backoffice-ui/src/paths/instance/templates/update/index.tsx +++ b/packages/merchant-backoffice-ui/src/paths/instance/templates/update/index.tsx @@ -99,7 +99,7 @@ export default function UpdateTemplate({ }); } }) - .catch((error: unknown) => { + .catch((error) => { setNotif({ message: i18n.str`Could not update template`, type: "ERROR", diff --git a/packages/merchant-backoffice-ui/src/paths/instance/templates/use/index.tsx b/packages/merchant-backoffice-ui/src/paths/instance/templates/use/index.tsx index d0d6d3c27..ebdb1a6fa 100644 --- a/packages/merchant-backoffice-ui/src/paths/instance/templates/use/index.tsx +++ b/packages/merchant-backoffice-ui/src/paths/instance/templates/use/index.tsx @@ -97,7 +97,7 @@ export default function TemplateUsePage({ }); } }) - .catch((error: unknown) => { + .catch((error) => { setNotif({ message: i18n.str`Could not create order from template`, type: "ERROR", diff --git a/packages/merchant-backoffice-ui/src/paths/instance/tokenfamilies/create/index.tsx b/packages/merchant-backoffice-ui/src/paths/instance/tokenfamilies/create/index.tsx index 8909a9cb6..34361fd56 100644 --- a/packages/merchant-backoffice-ui/src/paths/instance/tokenfamilies/create/index.tsx +++ b/packages/merchant-backoffice-ui/src/paths/instance/tokenfamilies/create/index.tsx @@ -60,7 +60,7 @@ export default function CreateTokenFamily({ onConfirm, onBack }: Props): VNode { }); } }) - .catch((error: unknown) => { + .catch((error) => { setNotif({ message: i18n.str`Could not create token family`, type: "ERROR", diff --git a/packages/merchant-backoffice-ui/src/paths/instance/tokenfamilies/update/index.tsx b/packages/merchant-backoffice-ui/src/paths/instance/tokenfamilies/update/index.tsx index c7341699a..287cc7a51 100644 --- a/packages/merchant-backoffice-ui/src/paths/instance/tokenfamilies/update/index.tsx +++ b/packages/merchant-backoffice-ui/src/paths/instance/tokenfamilies/update/index.tsx @@ -109,7 +109,7 @@ export default function UpdateTokenFamily({ }); } }) - .catch((error: unknown) => { + .catch((error) => { setNotif({ message: i18n.str`Could not update token family`, type: "ERROR", diff --git a/packages/merchant-backoffice-ui/src/paths/instance/transfers/create/index.tsx b/packages/merchant-backoffice-ui/src/paths/instance/transfers/create/index.tsx index 7c27d57c5..2f295fcc8 100644 --- a/packages/merchant-backoffice-ui/src/paths/instance/transfers/create/index.tsx +++ b/packages/merchant-backoffice-ui/src/paths/instance/transfers/create/index.tsx @@ -71,7 +71,7 @@ export default function CreateTransfer({ onConfirm, onBack }: Props): VNode { }); } }) - .catch((error: unknown) => { + .catch((error) => { setNotif({ message: i18n.str`Could not inform transfer`, type: "ERROR", diff --git a/packages/merchant-backoffice-ui/src/paths/instance/update/index.tsx b/packages/merchant-backoffice-ui/src/paths/instance/update/index.tsx index 918b39870..2b2327eb2 100644 --- a/packages/merchant-backoffice-ui/src/paths/instance/update/index.tsx +++ b/packages/merchant-backoffice-ui/src/paths/instance/update/index.tsx @@ -103,7 +103,7 @@ function CommonUpdate( } return updateInstance(state.token, d) .then(onConfirm) - .catch((error: unknown) => + .catch((error) => setNotif({ message: i18n.str`Failed to update instance`, type: "ERROR", diff --git a/packages/merchant-backoffice-ui/src/paths/instance/webhooks/create/index.tsx b/packages/merchant-backoffice-ui/src/paths/instance/webhooks/create/index.tsx index a97550234..6595879fb 100644 --- a/packages/merchant-backoffice-ui/src/paths/instance/webhooks/create/index.tsx +++ b/packages/merchant-backoffice-ui/src/paths/instance/webhooks/create/index.tsx @@ -61,7 +61,7 @@ export default function CreateWebhook({ onConfirm, onBack }: Props): VNode { }); } }) - .catch((error: unknown) => { + .catch((error) => { setNotif({ message: i18n.str`Could not create webhook`, type: "ERROR", diff --git a/packages/merchant-backoffice-ui/src/paths/instance/webhooks/list/index.tsx b/packages/merchant-backoffice-ui/src/paths/instance/webhooks/list/index.tsx index 6ba9e16c5..0e1c57839 100644 --- a/packages/merchant-backoffice-ui/src/paths/instance/webhooks/list/index.tsx +++ b/packages/merchant-backoffice-ui/src/paths/instance/webhooks/list/index.tsx @@ -96,7 +96,7 @@ export default function ListWebhooks({ onCreate, onSelect }: Props): VNode { }); } }) - .catch((error: unknown) => + .catch((error) => setNotif({ message: i18n.str`Could not delete the webhook`, type: "ERROR", diff --git a/packages/merchant-backoffice-ui/src/paths/instance/webhooks/update/index.tsx b/packages/merchant-backoffice-ui/src/paths/instance/webhooks/update/index.tsx index 0258e7bb0..83dea45eb 100644 --- a/packages/merchant-backoffice-ui/src/paths/instance/webhooks/update/index.tsx +++ b/packages/merchant-backoffice-ui/src/paths/instance/webhooks/update/index.tsx @@ -98,7 +98,7 @@ export default function UpdateWebhook({ } }) - .catch((error: unknown) => { + .catch((error) => { setNotif({ message: i18n.str`Could not update webhook`, type: "ERROR", diff --git a/packages/merchant-backoffice-ui/src/type-override.d.ts b/packages/merchant-backoffice-ui/src/type-override.d.ts new file mode 100644 index 000000000..d820aff57 --- /dev/null +++ b/packages/merchant-backoffice-ui/src/type-override.d.ts @@ -0,0 +1,32 @@ +/* + This file is part of GNU Taler + (C) 2021-2024 Taler Systems S.A. + + GNU Taler is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + +/** + * define unkown type of catch function + */ +interface Promise<T> { + /** + * Attaches a callback for only the rejection of the Promise. + * @param onrejected The callback to execute when the Promise is rejected. + * @returns A Promise for the completion of the callback. + */ + catch<TResult = never>( + onrejected?: + | ((reason: unknown) => TResult | PromiseLike<TResult>) + | undefined + | null, + ): Promise<T | TResult>; +} |