From 136115022aa609309e940eecb23dd5c0020e4115 Mon Sep 17 00:00:00 2001 From: filtered <176114999+webfiltered@users.noreply.github.com> Date: Fri, 13 Jun 2025 01:15:03 -0700 Subject: [PATCH 1/4] [TS] Remove unnecessary assertions --- src/stores/executionStore.ts | 60 +++++++++++------------------------- 1 file changed, 18 insertions(+), 42 deletions(-) diff --git a/src/stores/executionStore.ts b/src/stores/executionStore.ts index ea3bd36f93..a4c3fdae31 100644 --- a/src/stores/executionStore.ts +++ b/src/stores/executionStore.ts @@ -92,50 +92,26 @@ export const useExecutionStore = defineStore('execution', () => { }) function bindExecutionEvents() { - api.addEventListener( - 'execution_start', - handleExecutionStart as EventListener - ) - api.addEventListener( - 'execution_cached', - handleExecutionCached as EventListener - ) - api.addEventListener('executed', handleExecuted as EventListener) - api.addEventListener('executing', handleExecuting as EventListener) - api.addEventListener('progress', handleProgress as EventListener) - api.addEventListener('status', handleStatus as EventListener) - api.addEventListener( - 'execution_error', - handleExecutionError as EventListener - ) + api.addEventListener('execution_start', handleExecutionStart) + api.addEventListener('execution_cached', handleExecutionCached) + api.addEventListener('executed', handleExecuted) + api.addEventListener('executing', handleExecuting) + api.addEventListener('progress', handleProgress) + api.addEventListener('status', handleStatus) + api.addEventListener('execution_error', handleExecutionError) } - api.addEventListener('progress_text', handleProgressText as EventListener) - api.addEventListener( - 'display_component', - handleDisplayComponent as EventListener - ) + api.addEventListener('progress_text', handleProgressText) + api.addEventListener('display_component', handleDisplayComponent) function unbindExecutionEvents() { - api.removeEventListener( - 'execution_start', - handleExecutionStart as EventListener - ) - api.removeEventListener( - 'execution_cached', - handleExecutionCached as EventListener - ) - api.removeEventListener('executed', handleExecuted as EventListener) - api.removeEventListener('executing', handleExecuting as EventListener) - api.removeEventListener('progress', handleProgress as EventListener) - api.removeEventListener('status', handleStatus as EventListener) - api.removeEventListener( - 'execution_error', - handleExecutionError as EventListener - ) - api.removeEventListener( - 'progress_text', - handleProgressText as EventListener - ) + api.removeEventListener('execution_start', handleExecutionStart) + api.removeEventListener('execution_cached', handleExecutionCached) + api.removeEventListener('executed', handleExecuted) + api.removeEventListener('executing', handleExecuting) + api.removeEventListener('progress', handleProgress) + api.removeEventListener('status', handleStatus) + api.removeEventListener('execution_error', handleExecutionError) + api.removeEventListener('progress_text', handleProgressText) } function handleExecutionStart(e: CustomEvent) { @@ -184,7 +160,7 @@ export const useExecutionStore = defineStore('execution', () => { clientId.value = api.clientId // Once we've received the clientId we no longer need to listen - api.removeEventListener('status', handleStatus as EventListener) + api.removeEventListener('status', handleStatus) } } From 3ebb9837ad7b590a99c9609c7ff5132b7ec72eec Mon Sep 17 00:00:00 2001 From: filtered <176114999+webfiltered@users.noreply.github.com> Date: Fri, 13 Jun 2025 01:23:27 -0700 Subject: [PATCH 2/4] [TS] Fix incorrect type assertion --- vite.config.mts | 5 ++--- vite.electron.config.mts | 3 +-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/vite.config.mts b/vite.config.mts index eda339517d..89520cadf9 100644 --- a/vite.config.mts +++ b/vite.config.mts @@ -3,10 +3,9 @@ import dotenv from 'dotenv' import IconsResolver from 'unplugin-icons/resolver' import Icons from 'unplugin-icons/vite' import Components from 'unplugin-vue-components/vite' -import { defineConfig } from 'vite' +import { type UserConfig, defineConfig } from 'vite' import { createHtmlPlugin } from 'vite-plugin-html' import vueDevTools from 'vite-plugin-vue-devtools' -import type { UserConfigExport } from 'vitest/config' import { addElementVnodeExportPlugin, @@ -154,4 +153,4 @@ export default defineConfig({ optimizeDeps: { exclude: ['@comfyorg/litegraph', '@comfyorg/comfyui-electron-types'] } -}) as UserConfigExport +}) satisfies UserConfig as UserConfig diff --git a/vite.electron.config.mts b/vite.electron.config.mts index c2ad8ee04c..88413e38f6 100644 --- a/vite.electron.config.mts +++ b/vite.electron.config.mts @@ -1,6 +1,5 @@ import { Plugin, defineConfig } from 'vite' import { mergeConfig } from 'vite' -import type { UserConfig } from 'vitest/config' import baseConfig from './vite.config.mts' @@ -83,7 +82,7 @@ const mockElectronAPI: Plugin = { } export default mergeConfig( - baseConfig as unknown as UserConfig, + baseConfig, defineConfig({ plugins: [mockElectronAPI] }) From ac4dbed36080e97053b19567b0de9dfa9450ed54 Mon Sep 17 00:00:00 2001 From: filtered <176114999+webfiltered@users.noreply.github.com> Date: Fri, 13 Jun 2025 01:28:36 -0700 Subject: [PATCH 3/4] [TS] Remove unnecessary type assertions --- src/types/treeExplorerTypes.ts | 6 +++--- src/utils/treeUtil.ts | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/types/treeExplorerTypes.ts b/src/types/treeExplorerTypes.ts index 9c6aaf6281..7cc639be98 100644 --- a/src/types/treeExplorerTypes.ts +++ b/src/types/treeExplorerTypes.ts @@ -4,12 +4,12 @@ import type { InjectionKey, ModelRef } from 'vue' export interface TreeNode extends PrimeVueTreeNode { label: string - children?: TreeNode[] + children?: this[] } export interface TreeExplorerNode extends TreeNode { data?: T - children?: TreeExplorerNode[] + children?: this[] icon?: string /** * Function to override what icon to use for the node. @@ -62,7 +62,7 @@ export interface TreeExplorerNode extends TreeNode { } export interface RenderedTreeExplorerNode extends TreeExplorerNode { - children?: RenderedTreeExplorerNode[] + children?: this[] icon: string type: 'folder' | 'node' /** Total number of leaves in the subtree */ diff --git a/src/utils/treeUtil.ts b/src/utils/treeUtil.ts index f7aaabc74c..788f47e89f 100644 --- a/src/utils/treeUtil.ts +++ b/src/utils/treeUtil.ts @@ -116,7 +116,7 @@ export const findNodeByKey = ( return null } for (const child of root.children) { - const result = findNodeByKey(child as T, key) + const result = findNodeByKey(child, key) if (result) { return result } @@ -130,11 +130,11 @@ export const findNodeByKey = ( * @returns A deep clone of the node. */ export function cloneTree(node: T): T { - const clone: T = { ...node } as T + const clone = { ...node } // Clone children recursively if (node.children && node.children.length > 0) { - clone.children = node.children.map((child) => cloneTree(child as T)) + clone.children = node.children.map((child) => cloneTree(child)) } return clone From aaf2653cf9ca43081646922f0baee81852691f52 Mon Sep 17 00:00:00 2001 From: filtered <176114999+webfiltered@users.noreply.github.com> Date: Fri, 13 Jun 2025 01:37:14 -0700 Subject: [PATCH 4/4] [TS] Remove type overrides --- src/utils/nodeDefUtil.ts | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/utils/nodeDefUtil.ts b/src/utils/nodeDefUtil.ts index 836cd55157..8b130ff2dc 100644 --- a/src/utils/nodeDefUtil.ts +++ b/src/utils/nodeDefUtil.ts @@ -61,8 +61,8 @@ const mergeNumericInputSpec = ( } return mergeCommonInputSpec( - [type, { ...options1, ...mergedOptions }] as unknown as T, - [type, { ...options2, ...mergedOptions }] as unknown as T + [type, { ...options1, ...mergedOptions }] as T, + [type, { ...options2, ...mergedOptions }] as T ) } @@ -84,8 +84,8 @@ const mergeComboInputSpec = ( } return mergeCommonInputSpec( - ['COMBO', { ...options1, options: intersection }] as unknown as T, - ['COMBO', { ...options2, options: intersection }] as unknown as T + ['COMBO', { ...options1, options: intersection }] as T, + ['COMBO', { ...options2, options: intersection }] as T ) } @@ -107,9 +107,7 @@ const mergeCommonInputSpec = ( return value1 === value2 || (_.isNil(value1) && _.isNil(value2)) }) - return mergeIsValid - ? ([type, { ...options1, ...options2 }] as unknown as T) - : null + return mergeIsValid ? ([type, { ...options1, ...options2 }] as T) : null } /**