1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-19 01:33:33 +00:00

[STRICT TS] Migrate platform abstract services functions (#8527)

We currently use a callback syntax for abstract services. This syntax isn't completely strict compliant and will fail the strictPropertyInitialization check. We also currently don't get any compile time errors if we forget to implement a function.

To that end this PR updates all platform owned services to use the appropriate abstract keyword for non implemented functions. I also updated the fields to be actual functions and not properties.
This commit is contained in:
Oscar Hinton
2024-03-28 12:01:09 +01:00
committed by GitHub
parent d10c14791d
commit 2edc156dd6
25 changed files with 232 additions and 212 deletions

View File

@@ -17,9 +17,9 @@ export abstract class DerivedStateProvider {
* well as some memory persistent information.
* @param dependencies The dependencies of the derive function
*/
get: <TFrom, TTo, TDeps extends DerivedStateDependencies>(
abstract get<TFrom, TTo, TDeps extends DerivedStateDependencies>(
parentState$: Observable<TFrom>,
deriveDefinition: DeriveDefinition<TFrom, TTo, TDeps>,
dependencies: TDeps,
) => DerivedState<TTo>;
): DerivedState<TTo>;
}

View File

@@ -9,5 +9,5 @@ export abstract class GlobalStateProvider {
* Gets a {@link GlobalState} scoped to the given {@link KeyDefinition}
* @param keyDefinition - The {@link KeyDefinition} for which you want the state for.
*/
get: <T>(keyDefinition: KeyDefinition<T>) => GlobalState<T>;
abstract get<T>(keyDefinition: KeyDefinition<T>): GlobalState<T>;
}

View File

@@ -19,7 +19,7 @@ import { ActiveUserStateProvider, SingleUserStateProvider } from "./user-state.p
*/
export abstract class StateProvider {
/** @see{@link ActiveUserStateProvider.activeUserId$} */
activeUserId$: Observable<UserId | undefined>;
abstract activeUserId$: Observable<UserId | undefined>;
/**
* Gets a state observable for a given key and userId.
@@ -149,10 +149,10 @@ export abstract class StateProvider {
): SingleUserState<T>;
/** @see{@link GlobalStateProvider.get} */
getGlobal: <T>(keyDefinition: KeyDefinition<T>) => GlobalState<T>;
getDerived: <TFrom, TTo, TDeps extends DerivedStateDependencies>(
abstract getGlobal<T>(keyDefinition: KeyDefinition<T>): GlobalState<T>;
abstract getDerived<TFrom, TTo, TDeps extends DerivedStateDependencies>(
parentState$: Observable<TFrom>,
deriveDefinition: DeriveDefinition<TFrom, TTo, TDeps>,
dependencies: TDeps,
) => DerivedState<TTo>;
): DerivedState<TTo>;
}

View File

@@ -39,7 +39,7 @@ export abstract class ActiveUserStateProvider {
/**
* Convenience re-emission of active user ID from {@link AccountService.activeAccount$}
*/
activeUserId$: Observable<UserId | undefined>;
abstract activeUserId$: Observable<UserId | undefined>;
/**
* Gets a {@link ActiveUserState} scoped to the given {@link KeyDefinition}, but updates when active user changes such