fix(platform,renderer): remove 12 @ts-expect-error suppressions

Amp-Thread-ID: https://ampcode.com/threads/T-019bafa8-5813-717a-89bf-1ba8b4c4faff
Co-authored-by: Amp <amp@ampcode.com>
This commit is contained in:
DrJKL
2026-01-11 17:12:21 -08:00
parent e9e02c2c2a
commit 0590557e44
10 changed files with 53 additions and 32 deletions

View File

@@ -68,19 +68,19 @@ function getFormAttrs(item: FormItem) {
}
switch (item.type) {
case 'combo':
case 'radio':
attrs['options'] =
case 'radio': {
const options =
typeof item.options === 'function'
? // @ts-expect-error: Audit and deprecate usage of legacy options type:
// (value) => [string | {text: string, value: string}]
item.options(formValue.value)
? item.options(formValue.value)
: item.options
attrs['options'] = options
if (typeof item.options?.[0] !== 'string') {
if (options && typeof options[0] !== 'string') {
attrs['optionLabel'] = 'text'
attrs['optionValue'] = 'value'
}
break
}
}
return attrs
}

View File

@@ -40,11 +40,16 @@ const props = defineProps<{
}>()
const { t } = useI18n()
function translateOptions(options: (SettingOption | string)[]) {
const settingStore = useSettingStore()
const settingValue = computed(() => settingStore.get(props.setting.id))
function translateOptions(
options:
| (SettingOption | string)[]
| ((value: unknown) => (SettingOption | string)[])
) {
if (typeof options === 'function') {
// @ts-expect-error: Audit and deprecate usage of legacy options type:
// (value) => [string | {text: string, value: string}]
return translateOptions(options(props.setting.value ?? ''))
return translateOptions(options(settingValue.value ?? ''))
}
return options.map((option) => {
@@ -75,8 +80,6 @@ const formItem = computed(() => {
}
})
const settingStore = useSettingStore()
const settingValue = computed(() => settingStore.get(props.setting.id))
const updateSettingValue = async <K extends keyof Settings>(
newValue: Settings[K]
) => {

View File

@@ -52,12 +52,18 @@ export interface SettingParams<TValue = any> extends FormItem {
/**
* The base form item for rendering in a form.
*/
/**
* Legacy options function type for dynamic options.
* @deprecated Use static options array instead.
*/
type LegacyOptionsFunction = (value: unknown) => Array<string | SettingOption>
export interface FormItem {
name: string
type: SettingInputType | SettingCustomRenderer
tooltip?: string
attrs?: Record<string, unknown>
options?: Array<string | SettingOption>
options?: Array<string | SettingOption> | LegacyOptionsFunction
}
export interface ISettingGroup {

View File

@@ -6,8 +6,11 @@ import { useToastStore } from '@/platform/updates/common/toastStore'
import { useFrontendVersionMismatchWarning } from '@/platform/updates/common/useFrontendVersionMismatchWarning'
import { useVersionCompatibilityStore } from '@/platform/updates/common/versionCompatibilityStore'
declare const global: typeof globalThis & {
__COMFYUI_FRONTEND_VERSION__: string
}
// Mock globals
//@ts-expect-error Define global for the test
global.__COMFYUI_FRONTEND_VERSION__ = '1.0.0'
// Mock config first - this needs to be before any imports

View File

@@ -69,13 +69,13 @@ describe('parseComfyWorkflow', () => {
// Should automatically transform the legacy format object to array.
workflow.nodes[0].pos = { '0': 3, '1': 4 }
let validatedWorkflow = await validateComfyWorkflow(workflow)
// @ts-expect-error fixme ts strict error
expect(validatedWorkflow.nodes[0].pos).toEqual([3, 4])
expect(validatedWorkflow).not.toBeNull()
expect(validatedWorkflow!.nodes[0].pos).toEqual([3, 4])
workflow.nodes[0].pos = { 0: 3, 1: 4 }
validatedWorkflow = await validateComfyWorkflow(workflow)
// @ts-expect-error fixme ts strict error
expect(validatedWorkflow.nodes[0].pos).toEqual([3, 4])
expect(validatedWorkflow).not.toBeNull()
expect(validatedWorkflow!.nodes[0].pos).toEqual([3, 4])
// Should accept the legacy bugged format object.
// https://github.com/Comfy-Org/ComfyUI_frontend/issues/710
@@ -92,8 +92,8 @@ describe('parseComfyWorkflow', () => {
'9': 0
}
validatedWorkflow = await validateComfyWorkflow(workflow)
// @ts-expect-error fixme ts strict error
expect(validatedWorkflow.nodes[0].pos).toEqual([600, 340])
expect(validatedWorkflow).not.toBeNull()
expect(validatedWorkflow!.nodes[0].pos).toEqual([600, 340])
})
it('workflow.nodes.widget_values', async () => {
@@ -111,8 +111,8 @@ describe('parseComfyWorkflow', () => {
// dynamic widgets display.
workflow.nodes[0].widgets_values = { foo: 'bar' }
const validatedWorkflow = await validateComfyWorkflow(workflow)
// @ts-expect-error fixme ts strict error
expect(validatedWorkflow.nodes[0].widgets_values).toEqual({ foo: 'bar' })
expect(validatedWorkflow).not.toBeNull()
expect(validatedWorkflow!.nodes[0].widgets_values).toEqual({ foo: 'bar' })
})
it('workflow.links', async () => {

View File

@@ -383,8 +383,8 @@ describe('layoutStore CRDT operations', () => {
})
const originalTitleHeight = LiteGraph.NODE_TITLE_HEIGHT
// @ts-expect-error intentionally simulate undefined runtime value
LiteGraph.NODE_TITLE_HEIGHT = undefined
// Intentionally simulate undefined runtime value via Object.assign
Object.assign(LiteGraph, { NODE_TITLE_HEIGHT: undefined })
try {
layoutStore.setSource(LayoutSource.DOM)

View File

@@ -64,7 +64,6 @@ function draw() {
}
containerHeight.value = height
// Set node.canvasHeight for legacy widgets that use it (e.g., Impact Pack)
// @ts-expect-error canvasHeight is a custom property used by some extensions
node.canvasHeight = height
widgetInstance.y = 0
canvasEl.value.height = (height + 2) * scaleFactor

View File

@@ -376,13 +376,10 @@ Another line with more content.`
const vm = wrapper.vm as InstanceType<typeof WidgetMarkdown>
// Test that the component creates a textarea reference when entering edit mode
// @ts-expect-error - isEditing is not exposed
expect(vm.isEditing).toBe(false)
// @ts-expect-error - startEditing is not exposed
await vm.startEditing()
// @ts-expect-error - isEditing is not exposed
expect(vm.isEditing).toBe(true)
await wrapper.vm.$nextTick()

View File

@@ -29,6 +29,7 @@
<script setup lang="ts">
import Textarea from 'primevue/textarea'
import type { ComponentPublicInstance } from 'vue'
import { computed, nextTick, ref } from 'vue'
import type { SimplifiedWidget } from '@/types/simplifiedWidget'
@@ -42,7 +43,9 @@ const modelValue = defineModel<string>({ default: '' })
// State
const isEditing = ref(false)
const textareaRef = ref<InstanceType<typeof Textarea> | undefined>()
const textareaRef = ref<
(InstanceType<typeof Textarea> & ComponentPublicInstance) | undefined
>()
// Computed
const renderedHtml = computed(() => {
@@ -56,12 +59,17 @@ const startEditing = async () => {
isEditing.value = true
await nextTick()
// Focus the textarea
// @ts-expect-error - $el is an internal property of the Textarea component
textareaRef.value?.$el?.focus()
// Focus the textarea element inside the PrimeVue Textarea component
const el = textareaRef.value?.$el
if (el instanceof HTMLElement) el.focus()
}
const handleBlur = () => {
isEditing.value = false
}
defineExpose({
isEditing,
startEditing
})
</script>

View File

@@ -197,6 +197,11 @@ declare module '@/lib/litegraph/src/litegraph' {
pasteFile?(file: File): void
/** Callback for pasting multiple files into the node */
pasteFiles?(files: File[]): void
/**
* Custom property used by some extensions (e.g., Impact Pack) to store
* the canvas height for legacy widget rendering.
*/
canvasHeight?: number
}
/**
* Only used by the Primitive node. Primitive node is using the widget property