Skip to content

Commit

Permalink
remove all anys wooohoooo
Browse files Browse the repository at this point in the history
  • Loading branch information
M-Kusumgar committed Nov 14, 2024
1 parent f7dc06b commit bd3c2c3
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 18 deletions.
6 changes: 3 additions & 3 deletions app/static/src/apiService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ export interface API<S, E> {
type OnError = (failure: ResponseFailure) => void;
type OnSuccess = (success: ResponseSuccess) => void;

export class APIService<S extends string, E extends string> implements API<S, E> {
export class APIService<S extends string, E extends string, State> implements API<S, E> {
private readonly _commit: Commit;

private readonly _baseUrl: string;

constructor(context: AppCtx) {
constructor(context: AppCtx<State>) {
this._commit = context.commit;
this._baseUrl = (context.rootState as AppState).baseUrl!;
}
Expand Down Expand Up @@ -189,4 +189,4 @@ export class APIService<S extends string, E extends string> implements API<S, E>
}
}

export const api = <S extends string, E extends string>(ctx: AppCtx): APIService<S, E> => new APIService<S, E>(ctx);
export const api = <S extends string, E extends string, State>(ctx: AppCtx<State>): APIService<S, E, State> => new APIService<S, E, State>(ctx);
6 changes: 3 additions & 3 deletions app/static/src/csvUpload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ interface ParseError {
message: string;
}

export class CSVUpload<S extends string, E extends string> {
export class CSVUpload<S extends string, E extends string, State> {
private readonly _commit: Commit;

private _onError: OnError | null = null;
Expand All @@ -23,7 +23,7 @@ export class CSVUpload<S extends string, E extends string> {

private _postSuccess: PostSuccess | null = null;

constructor(context: AppCtx) {
constructor(context: AppCtx<State>) {
this._commit = context.commit;
}

Expand Down Expand Up @@ -100,4 +100,4 @@ export class CSVUpload<S extends string, E extends string> {
};
}

export const csvUpload = <S extends string, E extends string>(ctx: AppCtx): CSVUpload<S, E> => new CSVUpload<S, E>(ctx);
export const csvUpload = <S extends string, E extends string, State>(ctx: AppCtx<State>): CSVUpload<S, E, State> => new CSVUpload<S, E, State>(ctx);
7 changes: 4 additions & 3 deletions app/static/src/directives/tooltip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ export interface ToolTipSettings {
delayMs?: number;
}

type TooltipWithConfig = Tooltip & { _config: Tooltip.Options }

export default {
mounted(el: HTMLElement, binding: DirectiveBinding<string | ToolTipSettings>): void {
const { value } = binding;
Expand Down Expand Up @@ -39,8 +41,7 @@ export default {
beforeUpdate(el: HTMLElement, binding: DirectiveBinding<string | ToolTipSettings>): void {
const { value } = binding;

// eslint-disable-next-line @typescript-eslint/no-explicit-any
let tooltip = Tooltip.getInstance(el) as any;
let tooltip = Tooltip.getInstance(el) as TooltipWithConfig;

if (typeof value !== "string" && tooltip) {
const variant = value?.variant || "text";
Expand All @@ -57,7 +58,7 @@ export default {
customClass: variant === "text" ? "" : `tooltip-${variant}`,
animation: false,
delay: { show: value?.delayMs || 0, hide: 0 }
});
}) as TooltipWithConfig;
}
}

Expand Down
7 changes: 3 additions & 4 deletions app/static/src/excel/wodinExcelDownload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,18 @@ import { AppState } from "../store/appState/state";
import { AppCtx } from "../types/utilTypes";
import { ErrorsMutation } from "../store/errors/mutations";

export abstract class WodinExcelDownload {
export abstract class WodinExcelDownload<State> {
private readonly _fileName: string;

protected readonly _state: AppState;

// eslint-disable-next-line @typescript-eslint/no-explicit-any
protected readonly _rootGetters: any;
protected readonly _rootGetters: AppCtx<State>["rootGetters"];

protected readonly _commit: Commit;

protected readonly _workbook: XLSX.WorkBook;

constructor(context: AppCtx, fileName: string) {
constructor(context: AppCtx<State>, fileName: string) {
this._state = context.rootState;
this._rootGetters = context.rootGetters;
this._commit = context.commit;
Expand Down
4 changes: 2 additions & 2 deletions app/static/src/excel/wodinModelOutputDownload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import { FitState } from "../store/fit/state";
import { FitDataGetter } from "../store/fitData/getters";
import { GraphsGetter } from "../store/graphs/getters";

export class WodinModelOutputDownload extends WodinExcelDownload {
export class WodinModelOutputDownload<State> extends WodinExcelDownload<State> {
private readonly _points: number;

constructor(context: AppCtx, fileName: string, points: number) {
constructor(context: AppCtx<State>, fileName: string, points: number) {
super(context, fileName);
this._points = points;
}
Expand Down
2 changes: 1 addition & 1 deletion app/static/src/excel/wodinSensitivitySummaryDownload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const extremeSummarySheets: ExtremeSummarySheetSettings[] = [
{ name: "TimeAtMin", extremePrefix: SensitivityPlotExtremePrefix.time, extreme: SensitivityPlotExtreme.Min },
{ name: "TimeAtMax", extremePrefix: SensitivityPlotExtremePrefix.time, extreme: SensitivityPlotExtreme.Max }
];
export class WodinSensitivitySummaryDownload extends WodinExcelDownload {
export class WodinSensitivitySummaryDownload<State> extends WodinExcelDownload<State> {
private _addSummarySheetFromOdinSeriesSet = (data: OdinUserTypeSeriesSet, sheetName: string) => {
const sheetData = data.x.map((x: OdinUserType, index: number) => {
return {
Expand Down
2 changes: 1 addition & 1 deletion app/static/src/store/appState/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ async function immediateUploadState(context: ActionContext<AppState, AppState>)
const { appName, appsPath, sessionId } = state;

commit(AppStateMutation.SetStateUploadInProgress, true);
await api<AppStateMutation, ErrorsMutation>(context)
await api<AppStateMutation, ErrorsMutation, AppState>(context)
.withSuccess(AppStateMutation.SetPersisted)
.withError(ErrorsMutation.AddError)
.post(`/${appsPath}/${appName}/sessions/${sessionId}`, serialiseState(state));
Expand Down
2 changes: 1 addition & 1 deletion app/static/src/types/utilTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ import { ActionContext } from "vuex";

export type Dict<V> = { [k: string]: V };

export type AppCtx = ActionContext<unknown, AppState>;
export type AppCtx<S> = ActionContext<S, AppState>;

0 comments on commit bd3c2c3

Please sign in to comment.