taler-typescript-core

Wallet core logic and WebUIs for various components
Log | Files | Refs | Submodules | README | LICENSE

commit 2609c7359356f1e991e41eceb7221c424d53bd1b
parent c9c6425f9fe3e8d7beb1f6455906812000a42d4a
Author: Sebastian <sebasjm@gmail.com>
Date:   Thu, 11 Jul 2024 12:06:20 -0300

type guard: promise catch wont use any type

Diffstat:
Apackages/bank-ui/src/type-override.d.ts | 32++++++++++++++++++++++++++++++++
Mpackages/bank-ui/src/utils.ts | 2+-
Mpackages/merchant-backoffice-ui/src/paths/instance/accounts/create/index.tsx | 2+-
Mpackages/merchant-backoffice-ui/src/paths/instance/accounts/list/index.tsx | 2+-
Mpackages/merchant-backoffice-ui/src/paths/instance/accounts/update/index.tsx | 2+-
Mpackages/merchant-backoffice-ui/src/paths/instance/orders/create/index.tsx | 2+-
Mpackages/merchant-backoffice-ui/src/paths/instance/orders/details/index.tsx | 2+-
Mpackages/merchant-backoffice-ui/src/paths/instance/orders/list/index.tsx | 2+-
Mpackages/merchant-backoffice-ui/src/paths/instance/otp_devices/create/index.tsx | 2+-
Mpackages/merchant-backoffice-ui/src/paths/instance/otp_devices/list/index.tsx | 2+-
Mpackages/merchant-backoffice-ui/src/paths/instance/otp_devices/update/index.tsx | 2+-
Mpackages/merchant-backoffice-ui/src/paths/instance/products/create/index.tsx | 2+-
Mpackages/merchant-backoffice-ui/src/paths/instance/products/update/index.tsx | 2+-
Mpackages/merchant-backoffice-ui/src/paths/instance/templates/create/index.tsx | 2+-
Mpackages/merchant-backoffice-ui/src/paths/instance/templates/update/index.tsx | 2+-
Mpackages/merchant-backoffice-ui/src/paths/instance/templates/use/index.tsx | 2+-
Mpackages/merchant-backoffice-ui/src/paths/instance/tokenfamilies/create/index.tsx | 2+-
Mpackages/merchant-backoffice-ui/src/paths/instance/tokenfamilies/update/index.tsx | 2+-
Mpackages/merchant-backoffice-ui/src/paths/instance/transfers/create/index.tsx | 2+-
Mpackages/merchant-backoffice-ui/src/paths/instance/update/index.tsx | 2+-
Mpackages/merchant-backoffice-ui/src/paths/instance/webhooks/create/index.tsx | 2+-
Mpackages/merchant-backoffice-ui/src/paths/instance/webhooks/list/index.tsx | 2+-
Mpackages/merchant-backoffice-ui/src/paths/instance/webhooks/update/index.tsx | 2+-
Apackages/merchant-backoffice-ui/src/type-override.d.ts | 32++++++++++++++++++++++++++++++++
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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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>; +}