From 652cba9cfe0e9d2fc0959690e960581fb9c7fc0d Mon Sep 17 00:00:00 2001 From: Methapon Metanipat Date: Thu, 14 Nov 2024 17:56:33 +0700 Subject: [PATCH] refactor: add overloading for util function --- src/utils/relation.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/utils/relation.ts b/src/utils/relation.ts index 20290d2..3e96f11 100644 --- a/src/utils/relation.ts +++ b/src/utils/relation.ts @@ -28,6 +28,8 @@ export function whereAddressQuery(query: string) { ]; } -export function queryOrNot(query: string | boolean, where: T): T | undefined { - return !!query ? where : undefined; +export function queryOrNot(query: string | boolean, where: T): T | undefined; +export function queryOrNot(query: string | boolean, where: T, fallback: U): T | U; +export function queryOrNot(query: string | boolean, where: T, fallback?: U) { + return !!query ? where : fallback; }