1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

Cleanup types to remove multiple cast locations

Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
Sebastian Malton 2023-01-24 10:10:04 -05:00
parent 337189bc32
commit 4caf77aec6
4 changed files with 8 additions and 6 deletions

View File

@ -4,7 +4,7 @@
*/
import type Config from "conf";
import type { Options as ConfOptions } from "conf/dist/source/types";
import type { Migrations, Options as ConfOptions } from "conf/dist/source/types";
import type { IEqualsComparer } from "mobx";
import { reaction } from "mobx";
import { disposer, isPromiseLike } from "@k8slens/utilities";
@ -18,13 +18,15 @@ import type { GetBasenameOfPath } from "../path/get-basename.injectable";
import type { EnlistMessageChannelListener } from "@k8slens/messaging";
import { toJS } from "../utils";
export interface BaseStoreParams<T> extends ConfOptions<T> {
export interface BaseStoreParams<T> extends Omit<ConfOptions<T>, "migrations"> {
syncOptions?: {
fireImmediately?: boolean;
equals?: IEqualsComparer<T>;
};
readonly configName: string;
migrations?: Migrations<Record<string, unknown>>;
/**
* fromStore is called internally when a child class syncs with the file
* system.
@ -85,7 +87,7 @@ export class BaseStore<T extends object> {
const config = this.dependencies.getConfigurationFileModel({
projectName: "lens",
cwd: this.cwd(),
...this.params,
...this.params as ConfOptions<T>,
});
const res = this.params.fromStore(config.store);

View File

@ -40,7 +40,7 @@ export class ClusterStore {
equals: comparer.structural,
},
projectVersion: this.dependencies.storeMigrationVersion,
migrations: this.dependencies.migrations as unknown as Migrations<ClusterStoreModel>,
migrations: this.dependencies.migrations,
fromStore: action(({ clusters = [] }) => {
const currentClusters = new Map(this.clusters);
const newClusters = new Map<ClusterId, Cluster>();

View File

@ -39,7 +39,7 @@ export class UserStore {
this.store = this.dependencies.createBaseStore({
configName: "lens-user-store",
projectVersion: this.dependencies.storeMigrationVersion,
migrations: this.dependencies.migrations as unknown as Migrations<UserStoreModel>,
migrations: this.dependencies.migrations,
fromStore: action(({ preferences }) => {
this.dependencies.logger.debug("UserStore.fromStore()", { preferences });

View File

@ -22,7 +22,7 @@ import { persistStateToConfigInjectionToken } from "../common/base-store/save-to
import getBasenameOfPathInjectable from "../common/path/get-basename.injectable";
import { enlistMessageChannelListenerInjectionToken } from "@k8slens/messaging";
export interface ExtensionStoreParams<T extends object> extends BaseStoreParams<T> {
export interface ExtensionStoreParams<T extends object> extends Omit<BaseStoreParams<T>, "migrations"> {
migrations?: Migrations<T>;
}