Improve some type safety

This commit is contained in:
Matthias 2021-01-16 16:07:06 +01:00
parent 84e2632e13
commit 15945c0487
3 changed files with 10 additions and 11 deletions

View File

@ -34,7 +34,7 @@
<ReloadIcon />
</button>
<button
v-if="botState.forcebuy_enabled"
v-if="botState && botState.forcebuy_enabled"
class="btn btn-secondary btn-sm ml-1"
:disabled="!isTrading || !isRunning"
title="Force Buy - Immediately buy an asset at an optional price. Sells are then handled according to strategy rules."
@ -76,7 +76,7 @@ const ftbot = namespace('ftbot');
export default class BotControls extends Vue {
forcebuyShow = false;
@ftbot.State botState!: BotState;
@ftbot.State botState?: BotState;
@ftbot.Action startBot;
@ -93,7 +93,7 @@ export default class BotControls extends Vue {
@ftbot.Getter [BotStoreGetters.isWebserverMode]!: boolean;
get isRunning(): boolean {
return this.botState.state === 'running';
return this.botState?.state === 'running';
}
initiateForcebuy() {

View File

@ -1,5 +1,5 @@
<template>
<div>
<div v-if="botState">
<p>
Running Freqtrade <strong>{{ version }}</strong>
</p>
@ -49,7 +49,7 @@ export default class BotStatus extends Vue {
@ftbot.State profit;
@ftbot.State botState!: BotState;
@ftbot.State botState?: BotState;
formatPercent = formatPercent;

View File

@ -4,7 +4,6 @@ import {
BotState,
Trade,
PlotConfig,
EMPTY_PLOTCONFIG,
StrategyResult,
BalanceInterface,
DailyReturnValue,
@ -24,24 +23,24 @@ export interface FtbotStateType {
blacklist: string[];
// TODO: type me
profit: {};
botState: BotState | undefined;
botState?: BotState;
balance: BalanceInterface | {};
dailyStats: DailyReturnValue | {};
pairlistMethods: string[];
detailTradeId: number | undefined;
detailTradeId?: number;
selectedPair: string;
// TODO: type me
candleData: {};
// TODO: type me
history: {};
strategyPlotConfig: PlotConfig | {};
strategyPlotConfig?: PlotConfig;
customPlotConfig: PlotConfigStorage;
plotConfigName: string;
availablePlotConfigNames: string[];
strategyList: string[];
strategy: StrategyResult | {};
pairlist: string[];
currentLocks: LockResponse | undefined;
currentLocks?: LockResponse;
}
const state: FtbotStateType = {
version: '',
@ -62,7 +61,7 @@ const state: FtbotStateType = {
selectedPair: '',
candleData: {},
history: {},
strategyPlotConfig: {},
strategyPlotConfig: undefined,
customPlotConfig: {},
plotConfigName: getPlotConfigName(),
availablePlotConfigNames: getAllPlotConfigNames(),