Skip to content

Commit 2db29fc

Browse files
authored
[TS] Fix ts-strict errors in Vue components (Part 1) (#3119)
1 parent 329bdff commit 2db29fc

File tree

17 files changed

+60
-42
lines changed

17 files changed

+60
-42
lines changed

src/App.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ const handleKey = (e: KeyboardEvent) => {
2828
useEventListener(window, 'keydown', handleKey)
2929
useEventListener(window, 'keyup', handleKey)
3030
31-
const showContextMenu = (event: PointerEvent) => {
31+
const showContextMenu = (event: MouseEvent) => {
3232
const { target } = event
3333
switch (true) {
3434
case target instanceof HTMLTextAreaElement:

src/components/actionbar/ComfyQueueButton.vue

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,11 @@ const hasPendingTasks = computed(
135135
)
136136
137137
const commandStore = useCommandStore()
138-
const queuePrompt = (e: MouseEvent) => {
139-
const commandId = e.shiftKey ? 'Comfy.QueuePromptFront' : 'Comfy.QueuePrompt'
138+
const queuePrompt = (e: Event) => {
139+
const commandId =
140+
'shiftKey' in e && e.shiftKey
141+
? 'Comfy.QueuePromptFront'
142+
: 'Comfy.QueuePrompt'
140143
commandStore.execute(commandId)
141144
}
142145
</script>

src/components/bottomPanel/tabs/terminal/BaseTerminal.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ import { Ref, onUnmounted, ref } from 'vue'
1212
import { useTerminal } from '@/composables/bottomPanelTabs/useTerminal'
1313
1414
const emit = defineEmits<{
15-
created: [ReturnType<typeof useTerminal>, Ref<HTMLElement>]
15+
created: [ReturnType<typeof useTerminal>, Ref<HTMLElement | undefined>]
1616
unmounted: []
1717
}>()
18-
const terminalEl = ref<HTMLElement>()
19-
const rootEl = ref<HTMLElement>()
18+
const terminalEl = ref<HTMLElement | undefined>()
19+
const rootEl = ref<HTMLElement | undefined>()
2020
emit('created', useTerminal(terminalEl), rootEl)
2121
2222
onUnmounted(() => emit('unmounted'))

src/components/bottomPanel/tabs/terminal/CommandTerminal.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import BaseTerminal from './BaseTerminal.vue'
1313
1414
const terminalCreated = (
1515
{ terminal, useAutoSize }: ReturnType<typeof useTerminal>,
16-
root: Ref<HTMLElement>
16+
root: Ref<HTMLElement | undefined>
1717
) => {
1818
const terminalApi = electronAPI().Terminal
1919

src/components/bottomPanel/tabs/terminal/LogsTerminal.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const loading = ref(true)
2727
2828
const terminalCreated = (
2929
{ terminal, useAutoSize }: ReturnType<typeof useTerminal>,
30-
root: Ref<HTMLElement>
30+
root: Ref<HTMLElement | undefined>
3131
) => {
3232
// `autoCols` is false because we don't want the progress bar in the terminal
3333
// to render incorrectly as the progress bar is rendered based on the

src/components/common/DeviceInfo.vue

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
<div class="grid grid-cols-2 gap-2">
33
<template v-for="col in deviceColumns" :key="col.field">
44
<div class="font-medium">{{ col.header }}</div>
5-
<div>{{ formatValue(props.device[col.field], col.field) }}</div>
5+
<div>
6+
{{ formatValue(props.device[col.field], col.field) }}
7+
</div>
68
</template>
79
</div>
810
</template>
@@ -15,7 +17,7 @@ const props = defineProps<{
1517
device: DeviceStats
1618
}>()
1719
18-
const deviceColumns = [
20+
const deviceColumns: { field: keyof DeviceStats; header: string }[] = [
1921
{ field: 'name', header: 'Name' },
2022
{ field: 'type', header: 'Type' },
2123
{ field: 'vram_total', header: 'VRAM Total' },

src/components/common/EditableText.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,10 @@ const props = withDefaults(defineProps<EditableTextProps>(), {
3838
3939
const emit = defineEmits(['update:modelValue', 'edit'])
4040
const inputValue = ref<string>(props.modelValue)
41-
const inputRef = ref(null)
41+
const inputRef = ref<InstanceType<typeof InputText> | undefined>()
4242
4343
const blurInputElement = () => {
44+
// @ts-expect-error - $el is an internal property of the InputText component
4445
inputRef.value?.$el.blur()
4546
}
4647
const finishEditing = () => {
@@ -58,6 +59,7 @@ watch(
5859
: inputValue.value
5960
const start = 0
6061
const end = fileName.length
62+
// @ts-expect-error - $el is an internal property of the InputText component
6163
const inputElement = inputRef.value.$el
6264
inputElement.setSelectionRange?.(start, end)
6365
})

src/components/common/FormItem.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ function getFormAttrs(item: FormItem) {
7272
item.options(formValue.value)
7373
: item.options
7474
75-
if (typeof item.options[0] !== 'string') {
75+
if (typeof item.options?.[0] !== 'string') {
7676
attrs['optionLabel'] = 'text'
7777
attrs['optionValue'] = 'value'
7878
}

src/components/common/InputKnob.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ const updateValue = (newValue: number | null) => {
7676
7777
const displayValue = (value: number): string => {
7878
updateValue(value)
79-
const stepString = props.step.toString()
79+
const stepString = (props.step ?? 1).toString()
8080
const resolution = stepString.includes('.')
8181
? stepString.split('.')[1].length
8282
: 0

src/components/common/InputSlider.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<div class="input-slider flex flex-row items-center gap-2">
33
<Slider
44
:modelValue="modelValue"
5-
@update:modelValue="updateValue"
5+
@update:modelValue="(value) => updateValue(value as number)"
66
class="slider-part"
77
:class="sliderClass"
88
:min="min"

0 commit comments

Comments
 (0)