From db47b68795b07e53d678ce68e8f92253a79d0c61 Mon Sep 17 00:00:00 2001 From: Alec Rippberger Date: Tue, 8 Apr 2025 13:53:55 -0500 Subject: [PATCH] Remove ts-strict-ignore and fix strict typing errors --- apps/browser/src/popup/app.component.ts | 12 ++++++------ .../vault/services/vault-browser-state.service.ts | 6 ++++-- libs/common/src/vault/abstractions/cipher.service.ts | 2 +- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/apps/browser/src/popup/app.component.ts b/apps/browser/src/popup/app.component.ts index 408b217d0bc..1620a95a10f 100644 --- a/apps/browser/src/popup/app.component.ts +++ b/apps/browser/src/popup/app.component.ts @@ -1,5 +1,3 @@ -// FIXME: Update this file to be type safe and remove this and next line -// @ts-strict-ignore import { ChangeDetectorRef, Component, NgZone, OnDestroy, OnInit, inject } from "@angular/core"; import { takeUntilDestroyed } from "@angular/core/rxjs-interop"; import { NavigationEnd, Router, RouterOutlet } from "@angular/router"; @@ -46,8 +44,8 @@ import { DesktopSyncVerificationDialogComponent } from "./components/desktop-syn export class AppComponent implements OnInit, OnDestroy { private compactModeService = inject(PopupCompactModeService); - private lastActivity: Date; - private activeUserId: UserId; + private lastActivity: Date | null = null; + private activeUserId: UserId | null = null; private recordActivitySubject = new Subject(); private routerAnimations = false; @@ -85,7 +83,7 @@ export class AppComponent implements OnInit, OnDestroy { await this.clearComponentStates(); this.accountService.activeAccount$.pipe(takeUntil(this.destroy$)).subscribe((account) => { - this.activeUserId = account?.id; + this.activeUserId = account?.id ?? null; }); this.authService.activeAccountStatus$ @@ -186,7 +184,9 @@ export class AppComponent implements OnInit, OnDestroy { await this.clearComponentStates(); } if (url.startsWith("/tabs/")) { - await this.cipherService.setAddEditCipherInfo(null, this.activeUserId); + if (this.activeUserId) { + await this.cipherService.setAddEditCipherInfo(null, this.activeUserId); + } } (window as any).previousPopupUrl = url; diff --git a/apps/browser/src/vault/services/vault-browser-state.service.ts b/apps/browser/src/vault/services/vault-browser-state.service.ts index 58ce717bf1e..d8851958269 100644 --- a/apps/browser/src/vault/services/vault-browser-state.service.ts +++ b/apps/browser/src/vault/services/vault-browser-state.service.ts @@ -56,7 +56,9 @@ export class VaultBrowserStateService { return await firstValueFrom(this.vaultBrowserGroupingsComponentState$); } - async setBrowserGroupingsComponentState(value: BrowserGroupingsComponentState): Promise { + async setBrowserGroupingsComponentState( + value: BrowserGroupingsComponentState | null, + ): Promise { await this.activeUserVaultBrowserGroupingsComponentState.update(() => value, { shouldUpdate: (current) => !(current == null && value == null), }); @@ -66,7 +68,7 @@ export class VaultBrowserStateService { return await firstValueFrom(this.vaultBrowserComponentState$); } - async setBrowserVaultItemsComponentState(value: BrowserComponentState): Promise { + async setBrowserVaultItemsComponentState(value: BrowserComponentState | null): Promise { await this.activeUserVaultBrowserComponentState.update(() => value, { shouldUpdate: (current) => !(current == null && value == null), }); diff --git a/libs/common/src/vault/abstractions/cipher.service.ts b/libs/common/src/vault/abstractions/cipher.service.ts index 2d381faaa8d..f55435465bf 100644 --- a/libs/common/src/vault/abstractions/cipher.service.ts +++ b/libs/common/src/vault/abstractions/cipher.service.ts @@ -198,7 +198,7 @@ export abstract class CipherService implements UserKeyRotationDataProvider; abstract restoreManyWithServer(ids: string[], orgId?: string): Promise; abstract getKeyForCipherKeyDecryption(cipher: Cipher, userId: UserId): Promise; - abstract setAddEditCipherInfo(value: AddEditCipherInfo, userId: UserId): Promise; + abstract setAddEditCipherInfo(value: AddEditCipherInfo | null, userId: UserId): Promise; /** * Returns user ciphers re-encrypted with the new user key. * @param originalUserKey the original user key