From 3b155cc6e85314055f3745a8a0a311e19f95d4d9 Mon Sep 17 00:00:00 2001 From: jeffvli Date: Sun, 3 Dec 2023 22:15:03 -0800 Subject: [PATCH] Remove throw from log function - Typescript cannot determine if a function throws an error - Does not work as a type guard when using ts-rest --- src/logger.ts | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/src/logger.ts b/src/logger.ts index a3b15f160..9ecfe188f 100644 --- a/src/logger.ts +++ b/src/logger.ts @@ -1,4 +1,3 @@ -import console from 'console'; import dayjs from 'dayjs'; const reset = '\x1b[0m'; @@ -23,19 +22,10 @@ const baseLog = (errorType: 'error' | 'info' | 'success' | 'warn') => { break; } - return ( - text: string, - options?: { context?: Record; throwError?: boolean; toast?: boolean }, - ): null | Error => { - const { throwError } = options || {}; + return (text: string, options?: { context?: Record; toast?: boolean }): void => { + // const { toast } = options || {}; const now = dayjs().toISOString(); console.log(`${logString}${now}${text}${JSON.stringify(options?.context)}${reset}`); - - if (!throwError) { - return null; - } - - throw new Error(text); }; };