Skip to content

Commit e8997a7

Browse files
[TS] Fix ts-strict errors in Vue components (Part 2) (#3123)
Co-authored-by: Christian Byrne <[email protected]>
1 parent 0a6d3c0 commit e8997a7

File tree

19 files changed

+76
-49
lines changed

19 files changed

+76
-49
lines changed

src/components/dialog/content/PromptDialogContent.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,10 @@ const onConfirm = () => {
3535
useDialogStore().closeDialog()
3636
}
3737
38-
const inputRef = ref(null)
38+
const inputRef = ref<InstanceType<typeof InputText> | undefined>()
3939
const selectAllText = () => {
4040
if (!inputRef.value) return
41+
// @ts-expect-error - $el is an internal property of the InputText component
4142
const inputElement = inputRef.value.$el
4243
inputElement.setSelectionRange(0, inputElement.value.length)
4344
}

src/components/dialog/content/SettingDialogContent.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
scrollHeight="100%"
1616
:optionDisabled="
1717
(option: SettingTreeNode) =>
18-
!queryIsEmpty && !searchResultsCategories.has(option.label)
18+
!queryIsEmpty && !searchResultsCategories.has(option.label ?? '')
1919
"
2020
class="border-none w-full"
2121
/>
@@ -266,8 +266,8 @@ const handleSearch = (query: string) => {
266266
267267
const queryIsEmpty = computed(() => searchQuery.value.length === 0)
268268
const inSearch = computed(() => !queryIsEmpty.value && !searchInProgress.value)
269-
const tabValue = computed(() =>
270-
inSearch.value ? 'Search Results' : activeCategory.value?.label
269+
const tabValue = computed<string>(() =>
270+
inSearch.value ? 'Search Results' : activeCategory.value?.label ?? ''
271271
)
272272
// Don't allow null category to be set outside of search.
273273
// In search mode, the active category can be null to show all search results.

src/components/dialog/content/error/ReportIssuePanel.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ const createUser = (formData: IssueReportFormData): User => ({
187187
})
188188
189189
const createExtraData = async (formData: IssueReportFormData) => {
190-
const result = {}
190+
const result: Record<string, unknown> = {}
191191
const isChecked = (fieldValue: string) => formData[fieldValue]
192192
193193
await Promise.all(
@@ -243,7 +243,7 @@ const submit = async (event: FormSubmitEvent) => {
243243
toast.add({
244244
severity: 'error',
245245
summary: t('g.error'),
246-
detail: error.message,
246+
detail: error instanceof Error ? error.message : String(error),
247247
life: 3000
248248
})
249249
}

src/components/dialog/content/manager/ManagerDialogContent.vue

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383
<ContentDivider orientation="vertical" :width="0.2" />
8484
<div class="flex-1 flex flex-col isolate">
8585
<InfoPanel
86-
v-if="!hasMultipleSelections"
86+
v-if="!hasMultipleSelections && selectedNodePack"
8787
:node-pack="selectedNodePack"
8888
/>
8989
<InfoPanelMultiItem v-else :node-packs="selectedNodePacks" />
@@ -149,8 +149,8 @@ const isEmptySearch = computed(() => searchQuery.value === '')
149149
150150
const getInstalledSearchResults = async () => {
151151
if (isEmptySearch.value) return getInstalledPacks()
152-
return searchResults.value.filter((pack) =>
153-
comfyManagerStore.installedPacksIds.has(pack.name)
152+
return searchResults.value.filter(
153+
(pack) => pack.name && comfyManagerStore.installedPacksIds.has(pack.name)
154154
)
155155
}
156156
@@ -162,15 +162,16 @@ watchEffect(async () => {
162162
}
163163
})
164164
165-
const resultsWithKeys = computed(() =>
166-
displayPacks.value.map((item) => ({
167-
...item,
168-
key: item.id || item.name
169-
}))
165+
const resultsWithKeys = computed(
166+
() =>
167+
displayPacks.value.map((item) => ({
168+
...item,
169+
key: item.id || item.name
170+
})) as (components['schemas']['Node'] & { key: string })[]
170171
)
171172
172173
const selectedNodePacks = ref<components['schemas']['Node'][]>([])
173-
const selectedNodePack = computed(() =>
174+
const selectedNodePack = computed<components['schemas']['Node'] | null>(() =>
174175
selectedNodePacks.value.length === 1 ? selectedNodePacks.value[0] : null
175176
)
176177

src/components/dialog/content/manager/infoPanel/InfoPanelMultiItem.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ const getPackNodes = async (pack: components['schemas']['Node']) => {
4848
if (!comfyRegistryService.packNodesAvailable(pack)) return []
4949
return comfyRegistryService.getNodeDefs({
5050
packId: pack.id,
51-
versionId: pack.latest_version.id
51+
versionId: pack.latest_version?.id
5252
})
5353
}
5454

src/components/dialog/content/manager/infoPanel/tabs/NodesTabPanel.vue

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
<script setup lang="ts">
1818
import NodePreview from '@/components/node/NodePreview.vue'
19+
import { ComfyNodeDef } from '@/schemas/nodeDef/nodeDefSchemaV2'
1920
import { components } from '@/types/comfyRegistryTypes'
2021
2122
defineProps<{
@@ -24,16 +25,20 @@ defineProps<{
2425
}>()
2526
2627
// TODO: when registry returns node defs, use them here
27-
const placeholderNodeDef = {
28+
const placeholderNodeDef: ComfyNodeDef = {
29+
name: 'Sample Node',
2830
display_name: 'Sample Node',
2931
description: 'This is a sample node for preview purposes',
3032
inputs: {
3133
input1: { name: 'Input 1', type: 'IMAGE' },
3234
input2: { name: 'Input 2', type: 'CONDITIONING' }
3335
},
3436
outputs: [
35-
{ name: 'Output 1', type: 'IMAGE', index: 0 },
36-
{ name: 'Output 2', type: 'MASK', index: 1 }
37-
]
37+
{ name: 'Output 1', type: 'IMAGE', index: 0, is_list: false },
38+
{ name: 'Output 2', type: 'MASK', index: 1, is_list: false }
39+
],
40+
category: 'Utility',
41+
output_node: false,
42+
python_module: 'nodes'
3843
}
3944
</script>

src/components/dialog/content/manager/packCard/PackCard.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ const isUpdateAvailable = computed(() => {
128128
const latestVersion = nodePack.latest_version?.version
129129
if (!latestVersion) return false
130130
131-
const installedVersion = getInstalledPackVersion(nodePack.id)
131+
const installedVersion = getInstalledPackVersion(nodePack.id ?? '')
132132
133133
// Don't attempt to show update available for nightly GitHub packs
134134
if (installedVersion && !isSemVer(installedVersion)) return false

src/components/dialog/content/setting/ExtensionPanel.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
icon="pi pi-ellipsis-h"
5656
text
5757
severity="secondary"
58-
@click="menu.show($event)"
58+
@click="menu?.show($event)"
5959
/>
6060
<ContextMenu ref="menu" :model="contextMenuItems" />
6161
</template>

src/components/dialog/content/setting/KeybindingPanel.vue

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,10 @@ interface ICommandData {
157157
const commandsData = computed<ICommandData[]>(() => {
158158
return Object.values(commandStore.commands).map((command) => ({
159159
id: command.id,
160-
label: t(`commands.${normalizeI18nKey(command.id)}.label`, command.label),
160+
label: t(
161+
`commands.${normalizeI18nKey(command.id)}.label`,
162+
command.label ?? ''
163+
),
161164
keybinding: keybindingStore.getKeybindingByCommandId(command.id)
162165
}))
163166
})
@@ -166,7 +169,7 @@ const selectedCommandData = ref<ICommandData | null>(null)
166169
const editDialogVisible = ref(false)
167170
const newBindingKeyCombo = ref<KeyComboImpl | null>(null)
168171
const currentEditingCommand = ref<ICommandData | null>(null)
169-
const keybindingInput = ref(null)
172+
const keybindingInput = ref<InstanceType<typeof InputText> | null>(null)
170173
171174
const existingKeybindingOnCombo = computed<KeybindingImpl | null>(() => {
172175
if (!currentEditingCommand.value) {
@@ -201,6 +204,7 @@ watchEffect(() => {
201204
if (editDialogVisible.value) {
202205
// nextTick doesn't work here, so we use a timeout instead
203206
setTimeout(() => {
207+
// @ts-expect-error - $el is an internal property of the InputText component
204208
keybindingInput.value?.$el?.focus()
205209
}, 300)
206210
}

src/components/graph/GraphCanvas.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,9 @@ watchEffect(() => {
106106
107107
watchEffect(() => {
108108
const spellcheckEnabled = settingStore.get('Comfy.TextareaWidget.Spellcheck')
109-
const textareas = document.querySelectorAll('textarea.comfy-multiline-input')
109+
const textareas = document.querySelectorAll<HTMLTextAreaElement>(
110+
'textarea.comfy-multiline-input'
111+
)
110112
111113
textareas.forEach((textarea: HTMLTextAreaElement) => {
112114
textarea.spellcheck = spellcheckEnabled

0 commit comments

Comments
 (0)