refactor: add overloading for util function

This commit is contained in:
Methapon Metanipat 2024-11-14 17:56:33 +07:00
parent c9ee4c1a98
commit 652cba9cfe

View file

@ -28,6 +28,8 @@ export function whereAddressQuery(query: string) {
];
}
export function queryOrNot<T>(query: string | boolean, where: T): T | undefined {
return !!query ? where : undefined;
export function queryOrNot<T>(query: string | boolean, where: T): T | undefined;
export function queryOrNot<T, U>(query: string | boolean, where: T, fallback: U): T | U;
export function queryOrNot<T, U>(query: string | boolean, where: T, fallback?: U) {
return !!query ? where : fallback;
}