Skip to content

Commit

Permalink
Merge pull request #4512 from mirumee/fix/improve-maybe-util-types
Browse files Browse the repository at this point in the history
Improve maybe util function types
  • Loading branch information
maarcingebala committed Jul 24, 2019
2 parents 0a28e71 + 8a5a61d commit 962a50a
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion saleor/static/dashboard-next/misc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,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;
Expand Down

0 comments on commit 962a50a

Please sign in to comment.