From e0a47f49f16c634dd337a9a1db95a8c21b9c27ed Mon Sep 17 00:00:00 2001 From: Matthias Date: Mon, 20 Dec 2021 20:15:39 +0100 Subject: [PATCH] chore: Properly type alerts --- src/components/ftbot/BotAlerts.vue | 3 ++- src/store/modules/alerts.ts | 6 ++++-- src/types/alertTypes.ts | 4 ++++ 3 files changed, 10 insertions(+), 3 deletions(-) create mode 100644 src/types/alertTypes.ts diff --git a/src/components/ftbot/BotAlerts.vue b/src/components/ftbot/BotAlerts.vue index 13ea9be7..c9520e02 100644 --- a/src/components/ftbot/BotAlerts.vue +++ b/src/components/ftbot/BotAlerts.vue @@ -19,12 +19,13 @@ import { Component, Vue } from 'vue-property-decorator'; import { namespace } from 'vuex-class'; import { AlertActions } from '@/store/modules/alerts'; import StoreModules from '@/store/storeSubModules'; +import { AlertType } from '@/types/alertTypes'; const alerts = namespace(StoreModules.alerts); @Component({}) export default class BotAlerts extends Vue { - @alerts.State activeMessages; + @alerts.State activeMessages!: AlertType[]; @alerts.Action [AlertActions.removeAlert]; diff --git a/src/store/modules/alerts.ts b/src/store/modules/alerts.ts index 462cb636..d31749f6 100644 --- a/src/store/modules/alerts.ts +++ b/src/store/modules/alerts.ts @@ -1,3 +1,5 @@ +import { AlertType } from '@/types/alertTypes'; + export enum AlertActions { addAlert = 'addAlert', removeAlert = 'removeAlert', @@ -14,7 +16,7 @@ export default { activeMessages: [], }, mutations: { - [AlertMutations.addAlert](state, message) { + [AlertMutations.addAlert](state, message: AlertType) { console.log(`adding message '${message.message}' to message queue`); state.activeMessages.push(message); }, @@ -23,7 +25,7 @@ export default { }, }, actions: { - [AlertActions.addAlert]({ commit }, message) { + [AlertActions.addAlert]({ commit }, message: AlertType) { commit(AlertMutations.addAlert, message); }, [AlertActions.removeAlert]({ commit }) { diff --git a/src/types/alertTypes.ts b/src/types/alertTypes.ts new file mode 100644 index 00000000..dabafba0 --- /dev/null +++ b/src/types/alertTypes.ts @@ -0,0 +1,4 @@ +export interface AlertType { + message: string; + severity: string; +}