From 69f5455255cccf4989300394ffb4fb1d474e6615 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=9C=A8=20Audrey=20=E2=9C=A8?= Date: Mon, 11 Aug 2025 15:08:14 -0400 Subject: [PATCH] fix type errors --- .../password-authentication.component.ts | 3 ++- libs/common/src/tools/log/disabled-logger.ts | 13 +++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/apps/web/src/app/tools/send/send-access/password-authentication.component.ts b/apps/web/src/app/tools/send/send-access/password-authentication.component.ts index f4e759c0c2d..637eb6d4fc0 100644 --- a/apps/web/src/app/tools/send/send-access/password-authentication.component.ts +++ b/apps/web/src/app/tools/send/send-access/password-authentication.component.ts @@ -67,7 +67,8 @@ export class PasswordAuthenticationComponent { withLatestFrom(sendId$, this.formGroup.valueChanges), map(([, sendId, { password }]) => [sendId, password ?? ""] as const), concatMap((params) => this.access.authenticate$(...params)), - map((success) => (success ? "success" : "failed")), + // FIXME: remove type assertion once we're on a typescript version that properly infers the type + map((success) => (success ? "success" : "failed") as "success" | "failed"), takeUntilDestroyed(destroyRef), ) .subscribe({ diff --git a/libs/common/src/tools/log/disabled-logger.ts b/libs/common/src/tools/log/disabled-logger.ts index 53feb0c8b39..78ccb4c71d2 100644 --- a/libs/common/src/tools/log/disabled-logger.ts +++ b/libs/common/src/tools/log/disabled-logger.ts @@ -21,4 +21,17 @@ export const DISABLED_LOGGER: SemanticLogger = deepFreeze({ throw new Error(message); } }, + + panicWhen( + predicate: boolean, + content: Jsonify | string, + message?: string, + ): predicate is false | never { + if (predicate) { + // type conversion safe because Jsonify === string + this.panic(content as Jsonify, message); + } + + return !predicate; + }, });