Skip to content

Commit 2d930f0

Browse files
authored
Merge branch 'develop' into pedrolamas/job-queue-totals
2 parents ae6e4eb + 712e89a commit 2d930f0

File tree

7 files changed

+35
-30
lines changed

7 files changed

+35
-30
lines changed

Diff for: src/components/settings/PendingChangesDialog.vue

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export default class PendingChangesDialog extends Vue {
3232
const saveConfigPendingItems: KlipperPrinterConfig = this.$store.getters['printer/getSaveConfigPendingItems']
3333
3434
const { changed, deleted } = Object.entries(saveConfigPendingItems)
35-
.reduce((previous, [sectionName, sectionEntries]) => {
35+
.reduce<{ changed: string[], deleted: string[] }>((previous, [sectionName, sectionEntries]) => {
3636
if (sectionEntries === null) {
3737
previous.deleted.push(`# [${sectionName}]`)
3838
} else {
@@ -43,7 +43,7 @@ export default class PendingChangesDialog extends Vue {
4343
}
4444
4545
return previous
46-
}, { changed: [], deleted: [] } as { changed: string[], deleted: string[] })
46+
}, { changed: [], deleted: [] })
4747
4848
const lines = [...changed]
4949

Diff for: src/components/widgets/filesystem/FileSystemBrowser.vue

+8-3
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ export default class FileSystemBrowser extends Mixins(FilesMixin) {
243243
for (let i = 0; i < sortBy.length; i++) {
244244
const sortKey = sortBy[i]
245245
246-
const sortValues = [
246+
const sortValues: unknown[] = [
247247
get(a, sortKey),
248248
get(b, sortKey)
249249
]
@@ -259,12 +259,17 @@ export default class FileSystemBrowser extends Mixins(FilesMixin) {
259259
}
260260
261261
// If values are of type number, compare as number
262-
if (sortValues.every(x => typeof (x) === 'number' && !isNaN(x))) {
262+
if (
263+
typeof sortValues[0] === 'number' &&
264+
typeof sortValues[1] === 'number' &&
265+
!isNaN(sortValues[0]) &&
266+
!isNaN(sortValues[1])
267+
) {
263268
return sortValues[0] - sortValues[1]
264269
}
265270
266271
const sortValuesAsString = sortValues
267-
.map(s => (s || '').toString() as string)
272+
.map(s => s?.toString() ?? '')
268273
269274
if (this.textSortOrder === 'numeric-prefix') {
270275
const [sortA, sortB] = sortValuesAsString

Diff for: src/components/widgets/filesystem/setupMonaco.ts

+16-16
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ async function setupMonaco () {
146146
const linesContent = model.getLinesContent()
147147

148148
const sectionBlocks = linesContent
149-
.reduce((state, lineContent, index) => {
149+
.reduce<ReduceState<{ sectionName: string, hash: string, range: monaco.IRange }>>((state, lineContent, index) => {
150150
const section = /^\[([^\]]+)\]/.exec(lineContent)
151151

152152
if (section) {
@@ -177,7 +177,7 @@ async function setupMonaco () {
177177
}
178178

179179
return state
180-
}, { result: [] } as ReduceState<{ sectionName: string, hash: string, range: monaco.IRange }>)
180+
}, { result: [] })
181181
.result
182182

183183
return {
@@ -202,7 +202,7 @@ async function setupMonaco () {
202202
const linesContent = model.getLinesContent()
203203

204204
const sectionBlocks = linesContent
205-
.reduce((state, lineContent, index) => {
205+
.reduce<ReduceState<monaco.languages.FoldingRange>>((state, lineContent, index) => {
206206
const isSection = /^\[[^\]]+\]/.test(lineContent)
207207

208208
if (isSection) {
@@ -220,11 +220,11 @@ async function setupMonaco () {
220220
}
221221

222222
return state
223-
}, { result: [] } as ReduceState<monaco.languages.FoldingRange>)
223+
}, { result: [] })
224224
.result
225225

226226
const regionBlocks = linesContent
227-
.reduce((state, lineContent, index) => {
227+
.reduce<StackReduceState<number, monaco.languages.FoldingRange>>((state, lineContent, index) => {
228228
lineContent = lineContent.trim()
229229

230230
if (lineContent.length > 0) {
@@ -246,11 +246,11 @@ async function setupMonaco () {
246246
}
247247

248248
return state
249-
}, { stack: [], result: [] } as StackReduceState<number, monaco.languages.FoldingRange>)
249+
}, { stack: [], result: [] })
250250
.result
251251

252252
const commentBlocks = linesContent
253-
.reduce((state, lineContent, index) => {
253+
.reduce<ReduceState<monaco.languages.FoldingRange>>((state, lineContent, index) => {
254254
lineContent = lineContent.trim()
255255

256256
if (lineContent.length > 0) {
@@ -272,7 +272,7 @@ async function setupMonaco () {
272272
}
273273

274274
return state
275-
}, { result: [] } as ReduceState<monaco.languages.FoldingRange>)
275+
}, { result: [] })
276276
.result
277277

278278
return [
@@ -288,7 +288,7 @@ async function setupMonaco () {
288288
const linesContent = model.getLinesContent()
289289

290290
const layerBlocks = linesContent
291-
.reduce((state, lineContent, index) => {
291+
.reduce<ReduceState<monaco.languages.FoldingRange>>((state, lineContent, index) => {
292292
const isLayer = /^\s*SET_PRINT_STATS_INFO .*CURRENT_LAYER=/i.test(lineContent)
293293

294294
if (isLayer) {
@@ -306,11 +306,11 @@ async function setupMonaco () {
306306
}
307307

308308
return state
309-
}, { result: [] } as ReduceState<monaco.languages.FoldingRange>)
309+
}, { result: [] })
310310
.result
311311

312312
const objectBlocks = linesContent
313-
.reduce((state, lineContent, index) => {
313+
.reduce<ReduceState<monaco.languages.FoldingRange>>((state, lineContent, index) => {
314314
lineContent = lineContent.trim()
315315

316316
if (lineContent.length > 0) {
@@ -338,11 +338,11 @@ async function setupMonaco () {
338338
}
339339

340340
return state
341-
}, { result: [] } as ReduceState<monaco.languages.FoldingRange>)
341+
}, { result: [] })
342342
.result
343343

344344
const thumbnailBlocks = linesContent
345-
.reduce((state, lineContent, index) => {
345+
.reduce<ReduceState<monaco.languages.FoldingRange>>((state, lineContent, index) => {
346346
if (lineContent.startsWith('; thumbnail')) {
347347
const type = lineContent.substring(11).split(' ')[1]
348348

@@ -364,11 +364,11 @@ async function setupMonaco () {
364364
}
365365

366366
return state
367-
}, { result: [] } as ReduceState<monaco.languages.FoldingRange>)
367+
}, { result: [] })
368368
.result
369369

370370
const commentBlocks = linesContent
371-
.reduce((state, lineContent, index) => {
371+
.reduce<ReduceState<monaco.languages.FoldingRange>>((state, lineContent, index) => {
372372
lineContent = lineContent.trim()
373373

374374
if (lineContent.length > 0) {
@@ -390,7 +390,7 @@ async function setupMonaco () {
390390
}
391391

392392
return state
393-
}, { result: [] } as ReduceState<monaco.languages.FoldingRange>)
393+
}, { result: [] })
394394
.result
395395

396396
return [

Diff for: src/components/widgets/history/JobHistory.vue

+2-2
Original file line numberDiff line numberDiff line change
@@ -145,15 +145,15 @@ export default class JobHistory extends Mixins(FilesMixin) {
145145
146146
get auxiliaryDataHeaders (): AppDataTableHeader[] {
147147
const auxiliaryDataHeaders = this.history
148-
.reduce((headers, item) => {
148+
.reduce<Record<string, string>>((headers, item) => {
149149
if (item.auxiliary_data) {
150150
for (const auxiliaryDataItem of item.auxiliary_data) {
151151
headers[auxiliaryDataItem.name] = auxiliaryDataItem.description
152152
}
153153
}
154154
155155
return headers
156-
}, {} as Record<string, string>)
156+
}, {})
157157
158158
for (const sensor of this.sensors) {
159159
if (sensor.history_fields) {

Diff for: src/components/widgets/spoolman/SpoolmanCard.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ export default class SpoolmanCard extends Mixins(StateMixin) {
219219
return this.$store.getters['spoolman/getActiveSpool']
220220
}
221221
222-
get currency (): string | undefined {
222+
get currency (): string | null {
223223
return this.$store.state.spoolman.currency
224224
}
225225

Diff for: src/store/printer/getters.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -758,7 +758,7 @@ export const getters: GetterTree<PrinterState, RootState> = {
758758
] as const
759759

760760
const sensors = Object.keys(state.printer)
761-
.reduce((groups, item) => {
761+
.reduce<Record<string, Sensor>>((groups, item) => {
762762
const [type, nameFromSplit] = item.split(' ', 2)
763763
const name = nameFromSplit ?? item
764764

@@ -790,7 +790,7 @@ export const getters: GetterTree<PrinterState, RootState> = {
790790
}
791791

792792
return groups
793-
}, {} as Record<string, Sensor>)
793+
}, {})
794794

795795
return Object.values(sensors)
796796
.sort((a, b) => a.type.localeCompare(b.type) || a.name.localeCompare(b.name))
@@ -1044,11 +1044,11 @@ export const getters: GetterTree<PrinterState, RootState> = {
10441044
const knownCommands: GcodeHelp = rootGetters['console/getAllKnownCommands']
10451045

10461046
return Object.entries(knownCommands)
1047-
.reduce((availableCommands, [key, help]) => {
1047+
.reduce<GcodeCommands>((availableCommands, [key, help]) => {
10481048
availableCommands[key] = { help }
10491049

10501050
return availableCommands
1051-
}, {} as GcodeCommands)
1051+
}, {})
10521052
},
10531053

10541054
getIsManualProbeActive: (state) => {

Diff for: src/store/version/getters.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ export const getters: GetterTree<VersionState, RootState> = {
6868
const componentVersionInfo = state.version_info[component]
6969
if (componentVersionInfo && 'git_messages' in componentVersionInfo) {
7070
const result = [...componentVersionInfo.commits_behind]
71-
.reduce((groups, commitItem) => {
71+
.reduce<Record<number, CommitItem[]>>((groups, commitItem) => {
7272
const dateAndTime = new Date(+commitItem.date * 1000)
7373
const dateOnly = +(new Date(dateAndTime.getFullYear(), dateAndTime.getMonth(), dateAndTime.getDate()))
7474

@@ -79,7 +79,7 @@ export const getters: GetterTree<VersionState, RootState> = {
7979
}
8080

8181
return groups
82-
}, {} as Record<number, CommitItem[]>)
82+
}, {})
8383
return {
8484
keys: Object
8585
.keys(result)

0 commit comments

Comments
 (0)