Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Improve maybe util function types

Jakub Majorek8a5a61d823fc
diff --git a/saleor/static/dashboard-next/misc.ts b/saleor/static/dashboard-next/misc.ts
index c41a3b0e76..efc20b199f 100644
--- a/saleor/static/dashboard-next/misc.ts
+++ b/saleor/static/dashboard-next/misc.ts
@@ -145,7 +145,9 @@ export const translatedAuthorizationKeyTypes = () => ({
[AuthorizationKeyType.GOOGLE_OAUTH2]: i18n.t("Google OAuth2")
});
-export function maybe<T>(exp: () => T, d?: T) {
+export function maybe<T>(exp: () => T): T | undefined;
+export function maybe<T>(exp: () => T, d: T): T;
+export function maybe(exp: any, d?: any) {
try {
const result = exp();
return result === undefined ? d : result;