11import Vue from 'vue'
22import { GetterTree } from 'vuex'
3- import { SocketState , TimeEstimates } from './types'
3+ import { Heater , Fan , SocketState , TimeEstimates , Sensor , Chart , ChartDataSet } from './types'
44import { RootState } from '../types'
55import { chartConfiguration } from '@/globals'
66import { TinyColor } from '@ctrl/tinycolor'
@@ -85,12 +85,12 @@ export const getters: GetterTree<SocketState, RootState> = {
8585 /**
8686 * Return available heaters
8787 */
88- getHeaters : ( state ) => {
88+ getHeaters : ( state ) : Heater [ ] => {
8989 if (
9090 state . printer . heaters . available_heaters &&
9191 state . printer . heaters . available_heaters . length
9292 ) {
93- const r : any = [ ]
93+ const r : Heater [ ] = [ ]
9494 state . printer . heaters . available_heaters . forEach ( ( e : string ) => {
9595 const config = ( state . printer . configfile . config [ e ] ) ? state . printer . configfile . config [ e ] : undefined
9696 r . push ( {
@@ -100,7 +100,7 @@ export const getters: GetterTree<SocketState, RootState> = {
100100 maxTemp : ( config && config . max_temp ) ? parseInt ( config . max_temp ) : null
101101 } )
102102 } )
103- return r . sort ( ( a : any , b : any ) => {
103+ return r . sort ( ( a : Heater , b : Heater ) => {
104104 const name1 = a . name . toUpperCase ( )
105105 const name2 = b . name . toUpperCase ( )
106106 return ( name1 < name2 ) ? - 1 : ( name1 > name2 ) ? 1 : 0
@@ -112,12 +112,12 @@ export const getters: GetterTree<SocketState, RootState> = {
112112 /**
113113 * Return available temperature fans
114114 */
115- getFans : ( state ) => {
115+ getFans : ( state ) : Fan [ ] => {
116116 if (
117117 state . temperature_fans &&
118118 state . temperature_fans . length
119119 ) {
120- const r : any = [ ]
120+ const r : Fan [ ] = [ ]
121121 state . temperature_fans . forEach ( ( e : string ) => {
122122 const config = ( state . printer . configfile . config [ 'temperature_fan ' + e ] ) ? state . printer . configfile . config [ 'temperature_fan ' + e ] : undefined
123123 r . push ( {
@@ -135,12 +135,12 @@ export const getters: GetterTree<SocketState, RootState> = {
135135 /**
136136 * Return available temperature probes / sensors.
137137 */
138- getSensors : ( state ) => {
138+ getSensors : ( state ) : Sensor [ ] => {
139139 if (
140140 state . temperature_sensors &&
141141 state . temperature_sensors . length
142142 ) {
143- const r : any = [ ]
143+ const r : Sensor [ ] = [ ]
144144 state . temperature_sensors . forEach ( ( e : string ) => {
145145 r . push ( {
146146 name : e ,
@@ -180,7 +180,7 @@ export const getters: GetterTree<SocketState, RootState> = {
180180 } ,
181181
182182 getChartData : ( state ) => {
183- const chartData : { [ key : string ] : Array < { [ key : string ] : any } > } = {
183+ const chartData : Chart = {
184184 labels : [ ] ,
185185 datasets : [ ]
186186 }
@@ -190,7 +190,7 @@ export const getters: GetterTree<SocketState, RootState> = {
190190 // Beds should probably be some variation of blue;
191191 // Hotends should be some variation of red;
192192 // Other sensors can hue off'f green.
193- const defaults : { [ key : string ] : any } = {
193+ const defaults : ChartDataSet = {
194194 data : item . data ,
195195 label : item . label ,
196196 display : false ,
0 commit comments