diff --git a/src/extensions/core/groupNode.ts b/src/extensions/core/groupNode.ts index cbc8d2565..0dac84e94 100644 --- a/src/extensions/core/groupNode.ts +++ b/src/extensions/core/groupNode.ts @@ -196,8 +196,7 @@ export class GroupNodeConfig { primitiveToWidget: {} nodeInputs: {} outputVisibility: any[] - // @ts-expect-error fixme ts strict error - nodeDef: ComfyNodeDef + nodeDef: (ComfyNodeDef & { [GROUP]: GroupNodeConfig }) | undefined // @ts-expect-error fixme ts strict error inputs: any[] // @ts-expect-error fixme ts strict error @@ -231,8 +230,7 @@ export class GroupNodeConfig { output: [], output_name: [], output_is_list: [], - // @ts-expect-error Unused, doesn't exist - output_is_hidden: [], + output_node: false, // This is a lie (to satisfy the interface) name: source + SEPARATOR + this.name, display_name: this.name, category: 'group nodes' + (SEPARATOR + source), @@ -261,6 +259,7 @@ export class GroupNodeConfig { } // @ts-expect-error fixme ts strict error this.#convertedToProcess = null + if (!this.nodeDef) return await app.registerNodeDef(`${PREFIX}${SEPARATOR}` + this.name, this.nodeDef) useNodeDefStore().addNodeDef(this.nodeDef) } diff --git a/src/extensions/core/load3d/CameraManager.ts b/src/extensions/core/load3d/CameraManager.ts index c87d38483..c92190b80 100644 --- a/src/extensions/core/load3d/CameraManager.ts +++ b/src/extensions/core/load3d/CameraManager.ts @@ -13,8 +13,6 @@ export class CameraManager implements CameraManagerInterface { orthographicCamera: THREE.OrthographicCamera activeCamera: THREE.Camera - // @ts-expect-error unused variable - private renderer: THREE.WebGLRenderer private eventManager: EventManagerInterface private controls: OrbitControls | null = null @@ -42,10 +40,9 @@ export class CameraManager implements CameraManagerInterface { } constructor( - renderer: THREE.WebGLRenderer, + _renderer: THREE.WebGLRenderer, eventManager: EventManagerInterface ) { - this.renderer = renderer this.eventManager = eventManager this.perspectiveCamera = new THREE.PerspectiveCamera( diff --git a/src/extensions/core/load3d/SceneManager.ts b/src/extensions/core/load3d/SceneManager.ts index c03a43121..00a3383d6 100644 --- a/src/extensions/core/load3d/SceneManager.ts +++ b/src/extensions/core/load3d/SceneManager.ts @@ -27,13 +27,11 @@ export class SceneManager implements SceneManagerInterface { private renderer: THREE.WebGLRenderer private getActiveCamera: () => THREE.Camera - // @ts-expect-error unused variable - private getControls: () => OrbitControls constructor( renderer: THREE.WebGLRenderer, getActiveCamera: () => THREE.Camera, - getControls: () => OrbitControls, + _getControls: () => OrbitControls, eventManager: EventManagerInterface ) { this.renderer = renderer @@ -41,7 +39,6 @@ export class SceneManager implements SceneManagerInterface { this.scene = new THREE.Scene() this.getActiveCamera = getActiveCamera - this.getControls = getControls this.gridHelper = new THREE.GridHelper(20, 20) this.gridHelper.position.set(0, 0, 0) diff --git a/src/extensions/core/load3d/ViewHelperManager.ts b/src/extensions/core/load3d/ViewHelperManager.ts index 380153ed0..f7824f168 100644 --- a/src/extensions/core/load3d/ViewHelperManager.ts +++ b/src/extensions/core/load3d/ViewHelperManager.ts @@ -14,16 +14,13 @@ export class ViewHelperManager implements ViewHelperManagerInterface { private getActiveCamera: () => THREE.Camera private getControls: () => OrbitControls private eventManager: EventManagerInterface - // @ts-expect-error unused variable - private renderer: THREE.WebGLRenderer constructor( - renderer: THREE.WebGLRenderer, + _renderer: THREE.WebGLRenderer, getActiveCamera: () => THREE.Camera, getControls: () => OrbitControls, eventManager: EventManagerInterface ) { - this.renderer = renderer this.getActiveCamera = getActiveCamera this.getControls = getControls this.eventManager = eventManager diff --git a/src/lib/litegraph/src/LGraphButton.test.ts b/src/lib/litegraph/src/LGraphButton.test.ts index 83d17abc7..923dd4778 100644 --- a/src/lib/litegraph/src/LGraphButton.test.ts +++ b/src/lib/litegraph/src/LGraphButton.test.ts @@ -5,16 +5,14 @@ import { LGraphButton, Rectangle } from '@/lib/litegraph/src/litegraph' describe('LGraphButton', () => { describe('Constructor', () => { it('should create a button with default options', () => { - // @ts-expect-error TODO: Fix after merge - LGraphButton constructor type issues - const button = new LGraphButton({}) + const button = new LGraphButton({ text: '' }) expect(button).toBeInstanceOf(LGraphButton) expect(button.name).toBeUndefined() expect(button._last_area).toBeInstanceOf(Rectangle) }) it('should create a button with custom name', () => { - // @ts-expect-error TODO: Fix after merge - LGraphButton constructor type issues - const button = new LGraphButton({ name: 'test_button' }) + const button = new LGraphButton({ text: '', name: 'test_button' }) expect(button.name).toBe('test_button') }) @@ -158,9 +156,8 @@ describe('LGraphButton', () => { const button = new LGraphButton({ text: '→', fontSize: 20, - // @ts-expect-error TODO: Fix after merge - color property not defined in type - color: '#FFFFFF', - backgroundColor: '#333333', + fgColor: '#FFFFFF', + bgColor: '#333333', xOffset: -10, yOffset: 5 }) diff --git a/src/lib/litegraph/src/LGraphCanvas.titleButtons.test.ts b/src/lib/litegraph/src/LGraphCanvas.titleButtons.test.ts index 5c814f95e..6202bb33d 100644 --- a/src/lib/litegraph/src/LGraphCanvas.titleButtons.test.ts +++ b/src/lib/litegraph/src/LGraphCanvas.titleButtons.test.ts @@ -1,6 +1,7 @@ import { beforeEach, describe, expect, it, vi } from 'vitest' import { + LGraph, LGraphCanvas, LGraphNode, LiteGraph @@ -46,8 +47,8 @@ describe('LGraphCanvas Title Button Rendering', () => { canvasElement.getContext = vi.fn().mockReturnValue(ctx) - // @ts-expect-error TODO: Fix after merge - LGraphCanvas constructor type issues - canvas = new LGraphCanvas(canvasElement, null, { + const graph = new LGraph() + canvas = new LGraphCanvas(canvasElement, graph, { skip_render: true, skip_events: true }) @@ -56,18 +57,9 @@ describe('LGraphCanvas Title Button Rendering', () => { node.pos = [100, 200] node.size = [200, 100] - // Mock required methods node.drawTitleBarBackground = vi.fn() - // @ts-expect-error Property 'drawTitleBarText' does not exist on type 'LGraphNode' - node.drawTitleBarText = vi.fn() node.drawBadges = vi.fn() - // @ts-expect-error TODO: Fix after merge - drawToggles not defined in type - node.drawToggles = vi.fn() - // @ts-expect-error TODO: Fix after merge - drawNodeShape not defined in type - node.drawNodeShape = vi.fn() node.drawSlots = vi.fn() - // @ts-expect-error TODO: Fix after merge - drawContent not defined in type - node.drawContent = vi.fn() node.drawWidgets = vi.fn() node.drawCollapsedSlots = vi.fn() node.drawTitleBox = vi.fn() @@ -75,24 +67,31 @@ describe('LGraphCanvas Title Button Rendering', () => { node.drawProgressBar = vi.fn() node._setConcreteSlots = vi.fn() node.arrange = vi.fn() - // @ts-expect-error TODO: Fix after merge - isSelectable not defined in type - node.isSelectable = vi.fn().mockReturnValue(true) + + const nodeWithMocks = node as LGraphNode & { + drawTitleBarText: ReturnType + drawToggles: ReturnType + drawNodeShape: ReturnType + drawContent: ReturnType + isSelectable: ReturnType + } + nodeWithMocks.drawTitleBarText = vi.fn() + nodeWithMocks.drawToggles = vi.fn() + nodeWithMocks.drawNodeShape = vi.fn() + nodeWithMocks.drawContent = vi.fn() + nodeWithMocks.isSelectable = vi.fn().mockReturnValue(true) }) describe('drawNode title button rendering', () => { it('should render visible title buttons', () => { const button1 = node.addTitleButton({ name: 'button1', - text: 'A', - // @ts-expect-error TODO: Fix after merge - visible property not in LGraphButtonOptions - visible: true + text: 'A' }) const button2 = node.addTitleButton({ name: 'button2', - text: 'B', - // @ts-expect-error TODO: Fix after merge - visible property not in LGraphButtonOptions - visible: true + text: 'B' }) // Mock button methods @@ -127,9 +126,7 @@ describe('LGraphCanvas Title Button Rendering', () => { it('should skip invisible title buttons', () => { const visibleButton = node.addTitleButton({ name: 'visible', - text: 'V', - // @ts-expect-error TODO: Fix after merge - visible property not in LGraphButtonOptions - visible: true + text: 'V' }) const invisibleButton = node.addTitleButton({ @@ -171,9 +168,7 @@ describe('LGraphCanvas Title Button Rendering', () => { for (let i = 0; i < 3; i++) { const button = node.addTitleButton({ name: `button${i}`, - text: String(i), - // @ts-expect-error TODO: Fix after merge - visible property not in LGraphButtonOptions - visible: true + text: String(i) }) button.getWidth = vi.fn().mockReturnValue(15) // All same width for simplicity const spy = vi.spyOn(button, 'draw') @@ -196,18 +191,12 @@ describe('LGraphCanvas Title Button Rendering', () => { it('should render buttons in low quality mode', () => { const button = node.addTitleButton({ name: 'test', - text: 'T', - // @ts-expect-error TODO: Fix after merge - visible property not in LGraphButtonOptions - visible: true + text: 'T' }) button.getWidth = vi.fn().mockReturnValue(20) const drawSpy = vi.spyOn(button, 'draw') - // Set low quality rendering - // @ts-expect-error TODO: Fix after merge - lowQualityRenderingRequired not defined in type - canvas.lowQualityRenderingRequired = true - canvas.drawNode(node, ctx) // Buttons should still be rendered in low quality mode @@ -219,16 +208,12 @@ describe('LGraphCanvas Title Button Rendering', () => { it('should handle buttons with different widths', () => { const smallButton = node.addTitleButton({ name: 'small', - text: 'S', - // @ts-expect-error TODO: Fix after merge - visible property not in LGraphButtonOptions - visible: true + text: 'S' }) const largeButton = node.addTitleButton({ name: 'large', - text: 'LARGE', - // @ts-expect-error TODO: Fix after merge - visible property not in LGraphButtonOptions - visible: true + text: 'LARGE' }) smallButton.getWidth = vi.fn().mockReturnValue(15) @@ -256,9 +241,7 @@ describe('LGraphCanvas Title Button Rendering', () => { const button = node.addTitleButton({ name: 'test', - text: 'X', - // @ts-expect-error TODO: Fix after merge - visible property not in LGraphButtonOptions - visible: true + text: 'X' }) button.getWidth = vi.fn().mockReturnValue(20) diff --git a/src/lib/litegraph/src/LGraphCanvas.ts b/src/lib/litegraph/src/LGraphCanvas.ts index 7792260a4..7e613c47c 100644 --- a/src/lib/litegraph/src/LGraphCanvas.ts +++ b/src/lib/litegraph/src/LGraphCanvas.ts @@ -969,10 +969,8 @@ export class LGraphCanvas implements CustomEventDispatcher } static onGroupAdd( - // @ts-expect-error - unused parameter - info: unknown, - // @ts-expect-error - unused parameter - entry: unknown, + _info: unknown, + _entry: unknown, mouse_event: MouseEvent ): void { const canvas = LGraphCanvas.active_canvas @@ -1020,10 +1018,8 @@ export class LGraphCanvas implements CustomEventDispatcher } static onNodeAlign( - // @ts-expect-error - unused parameter - value: IContextMenuValue, - // @ts-expect-error - unused parameter - options: IContextMenuOptions, + _value: IContextMenuValue, + _options: IContextMenuOptions, event: MouseEvent, prev_menu: ContextMenu, node: LGraphNode @@ -1046,10 +1042,8 @@ export class LGraphCanvas implements CustomEventDispatcher } static onGroupAlign( - // @ts-expect-error - unused parameter - value: IContextMenuValue, - // @ts-expect-error - unused parameter - options: IContextMenuOptions, + _value: IContextMenuValue, + _options: IContextMenuOptions, event: MouseEvent, prev_menu: ContextMenu ): void { @@ -1070,10 +1064,8 @@ export class LGraphCanvas implements CustomEventDispatcher } static createDistributeMenu( - // @ts-expect-error - unused parameter - value: IContextMenuValue, - // @ts-expect-error - unused parameter - options: IContextMenuOptions, + _value: IContextMenuValue, + _options: IContextMenuOptions, event: MouseEvent, prev_menu: ContextMenu ): void { @@ -1095,16 +1087,13 @@ export class LGraphCanvas implements CustomEventDispatcher } static onMenuAdd( - // @ts-expect-error - unused parameter - value: unknown, - // @ts-expect-error - unused parameter - options: unknown, + _value: unknown, + _options: unknown, e: MouseEvent, prev_menu?: ContextMenu, callback?: (node: LGraphNode | null) => void ): boolean | undefined { const canvas = LGraphCanvas.active_canvas - const ref_window = canvas.getCanvasWindow() const { graph } = canvas if (!graph) return @@ -1155,14 +1144,7 @@ export class LGraphCanvas implements CustomEventDispatcher value: category_path, content: name, has_submenu: true, - callback: function ( - value, - // @ts-expect-error - unused parameter - event, - // @ts-expect-error - unused parameter - mouseEvent, - contextMenu - ) { + callback: function (value, _event, _mouseEvent, contextMenu) { inner_onMenuAdded(value.value, contextMenu) } }) @@ -1181,14 +1163,7 @@ export class LGraphCanvas implements CustomEventDispatcher value: node.type, content: node.title, has_submenu: false, - callback: function ( - value, - // @ts-expect-error - unused parameter - event, - // @ts-expect-error - unused parameter - mouseEvent, - contextMenu - ) { + callback: function (value, _event, _mouseEvent, contextMenu) { if (!canvas.graph) throw new NullGraphError() const first_event = contextMenu.getFirstEvent() @@ -1213,12 +1188,7 @@ export class LGraphCanvas implements CustomEventDispatcher entries.push(entry) } - new LiteGraph.ContextMenu( - entries, - { event: e, parentMenu: prev_menu }, - // @ts-expect-error - extra parameter - ref_window - ) + new LiteGraph.ContextMenu(entries, { event: e, parentMenu: prev_menu }) } } @@ -1227,8 +1197,7 @@ export class LGraphCanvas implements CustomEventDispatcher /** @param _options Parameter is never used */ static showMenuNodeOptionalOutputs( - // @ts-expect-error - unused parameter - v: unknown, + _v: unknown, /** Unused - immediately overwritten */ _options: INodeOutputSlot[], e: MouseEvent, @@ -1312,8 +1281,7 @@ export class LGraphCanvas implements CustomEventDispatcher /** @param value Parameter is never used */ static onShowMenuNodeProperties( value: NodeProperty | undefined, - // @ts-expect-error - unused parameter - options: unknown, + _options: unknown, e: MouseEvent, prev_menu: ContextMenu, node: LGraphNode @@ -1321,7 +1289,6 @@ export class LGraphCanvas implements CustomEventDispatcher if (!node || !node.properties) return const canvas = LGraphCanvas.active_canvas - const ref_window = canvas.getCanvasWindow() const entries: IContextMenuValue[] = [] for (const i in node.properties) { @@ -1344,23 +1311,20 @@ export class LGraphCanvas implements CustomEventDispatcher return } - new LiteGraph.ContextMenu( - entries, - { - event: e, - callback: inner_clicked, - parentMenu: prev_menu, - allow_html: true, - node - }, - // @ts-expect-error Unused - ref_window - ) + new LiteGraph.ContextMenu(entries, { + event: e, + callback: inner_clicked, + parentMenu: prev_menu, + node + }) - function inner_clicked(this: ContextMenuDivElement, v: { value: any }) { - if (!node) return + function inner_clicked( + this: ContextMenu, + v?: string | IContextMenuValue + ) { + if (!node || typeof v === 'string' || !v?.value) return - const rect = this.getBoundingClientRect() + const rect = this.root.getBoundingClientRect() canvas.showEditPropertyValue(node, v.value, { position: [rect.left, rect.top] }) @@ -1377,14 +1341,10 @@ export class LGraphCanvas implements CustomEventDispatcher } static onMenuResizeNode( - // @ts-expect-error - unused parameter - value: IContextMenuValue, - // @ts-expect-error - unused parameter - options: IContextMenuOptions, - // @ts-expect-error - unused parameter - e: MouseEvent, - // @ts-expect-error - unused parameter - menu: ContextMenu, + _value: IContextMenuValue, + _options: IContextMenuOptions, + _e: MouseEvent, + _menu: ContextMenu, node: LGraphNode ): void { if (!node) return @@ -1411,11 +1371,9 @@ export class LGraphCanvas implements CustomEventDispatcher // TODO refactor :: this is used fot title but not for properties! static onShowPropertyEditor( item: { property: keyof LGraphNode; type: string }, - // @ts-expect-error - unused parameter - options: IContextMenuOptions, + _options: IContextMenuOptions, e: MouseEvent, - // @ts-expect-error - unused parameter - menu: ContextMenu, + _menu: ContextMenu, node: LGraphNode ): void { const property = item.property || 'title' @@ -1485,11 +1443,10 @@ export class LGraphCanvas implements CustomEventDispatcher input.focus() - let dialogCloseTimer: number + let dialogCloseTimer: ReturnType | undefined dialog.addEventListener('mouseleave', function () { if (LiteGraph.dialog_close_on_mouse_leave) { if (!dialog.is_modified && LiteGraph.dialog_close_on_mouse_leave) { - // @ts-expect-error - setTimeout type dialogCloseTimer = setTimeout( dialog.close, LiteGraph.dialog_close_on_mouse_leave_delay @@ -1544,14 +1501,10 @@ export class LGraphCanvas implements CustomEventDispatcher } static onMenuNodeCollapse( - // @ts-expect-error - unused parameter - value: IContextMenuValue, - // @ts-expect-error - unused parameter - options: IContextMenuOptions, - // @ts-expect-error - unused parameter - e: MouseEvent, - // @ts-expect-error - unused parameter - menu: ContextMenu, + _value: IContextMenuValue, + _options: IContextMenuOptions, + _e: MouseEvent, + _menu: ContextMenu, node: LGraphNode ): void { if (!node.graph) throw new NullGraphError() @@ -1578,14 +1531,10 @@ export class LGraphCanvas implements CustomEventDispatcher } static onMenuToggleAdvanced( - // @ts-expect-error - unused parameter - value: IContextMenuValue, - // @ts-expect-error - unused parameter - options: IContextMenuOptions, - // @ts-expect-error - unused parameter - e: MouseEvent, - // @ts-expect-error - unused parameter - menu: ContextMenu, + _value: IContextMenuValue, + _options: IContextMenuOptions, + _e: MouseEvent, + _menu: ContextMenu, node: LGraphNode ): void { if (!node.graph) throw new NullGraphError() @@ -1610,10 +1559,8 @@ export class LGraphCanvas implements CustomEventDispatcher } static onMenuNodeMode( - // @ts-expect-error - unused parameter - value: IContextMenuValue, - // @ts-expect-error - unused parameter - options: IContextMenuOptions, + _value: IContextMenuValue, + _options: IContextMenuOptions, e: MouseEvent, menu: ContextMenu, node: LGraphNode @@ -1657,8 +1604,7 @@ export class LGraphCanvas implements CustomEventDispatcher /** @param value Parameter is never used */ static onMenuNodeColors( value: IContextMenuValue, - // @ts-expect-error - unused parameter - options: IContextMenuOptions, + _options: IContextMenuOptions, e: MouseEvent, menu: ContextMenu, node: LGraphNode @@ -1719,10 +1665,8 @@ export class LGraphCanvas implements CustomEventDispatcher } static onMenuNodeShapes( - // @ts-expect-error - unused parameter - value: IContextMenuValue<(typeof LiteGraph.VALID_SHAPES)[number]>, - // @ts-expect-error - unused parameter - options: IContextMenuOptions<(typeof LiteGraph.VALID_SHAPES)[number]>, + _value: IContextMenuValue<(typeof LiteGraph.VALID_SHAPES)[number]>, + _options: IContextMenuOptions<(typeof LiteGraph.VALID_SHAPES)[number]>, e: MouseEvent, menu?: ContextMenu<(typeof LiteGraph.VALID_SHAPES)[number]>, node?: LGraphNode @@ -3596,13 +3540,16 @@ export class LGraphCanvas implements CustomEventDispatcher this.node_over?.onMouseUp?.( e, [x - this.node_over.pos[0], y - this.node_over.pos[1]], - // @ts-expect-error - extra parameter this ) - this.node_capturing_input?.onMouseUp?.(e, [ - x - this.node_capturing_input.pos[0], - y - this.node_capturing_input.pos[1] - ]) + this.node_capturing_input?.onMouseUp?.( + e, + [ + x - this.node_capturing_input.pos[0], + y - this.node_capturing_input.pos[1] + ], + this + ) } } else if (e.button === 1) { // middle button @@ -4599,9 +4546,8 @@ export class LGraphCanvas implements CustomEventDispatcher /** * converts a coordinate from graph coordinates to canvas2D coordinates */ - convertOffsetToCanvas(pos: Point, out: Point): Point { - // @ts-expect-error Unused param - return this.ds.convertOffsetToCanvas(pos, out) + convertOffsetToCanvas(pos: Point, _out?: Point): Point { + return this.ds.convertOffsetToCanvas(pos) } /** @@ -6144,11 +6090,7 @@ export class LGraphCanvas implements CustomEventDispatcher /** * draws every group area in the background */ - drawGroups( - // @ts-expect-error - unused parameter - canvas: HTMLCanvasElement, - ctx: CanvasRenderingContext2D - ): void { + drawGroups(_canvas: HTMLCanvasElement, ctx: CanvasRenderingContext2D): void { if (!this.graph) return const groups = this.graph._groups @@ -6242,8 +6184,7 @@ export class LGraphCanvas implements CustomEventDispatcher function inner_clicked( this: LGraphCanvas, v: string, - // @ts-expect-error - unused parameter - options: unknown, + _options: unknown, e: MouseEvent ) { if (!graph) throw new NullGraphError() @@ -6762,13 +6703,12 @@ export class LGraphCanvas implements CustomEventDispatcher if (this.ds.scale > 1) dialog.style.transform = `scale(${this.ds.scale})` - let dialogCloseTimer: number + let dialogCloseTimer: ReturnType | undefined let prevent_timeout = 0 LiteGraph.pointerListenerAdd(dialog, 'leave', function () { if (prevent_timeout) return if (LiteGraph.dialog_close_on_mouse_leave) { if (!dialog.is_modified && LiteGraph.dialog_close_on_mouse_leave) { - // @ts-expect-error - setTimeout type dialogCloseTimer = setTimeout( dialog.close, LiteGraph.dialog_close_on_mouse_leave_delay @@ -6957,7 +6897,7 @@ export class LGraphCanvas implements CustomEventDispatcher if (options.hide_on_mouse_leave) { // FIXME: Remove "any" kludge let prevent_timeout: any = false - let timeout_close: number | null = null + let timeout_close: ReturnType | null = null LiteGraph.pointerListenerAdd(dialog, 'enter', function () { if (timeout_close) { clearTimeout(timeout_close) @@ -6969,7 +6909,6 @@ export class LGraphCanvas implements CustomEventDispatcher const hideDelay = options.hide_on_mouse_leave const delay = typeof hideDelay === 'number' ? hideDelay : 500 - // @ts-expect-error - setTimeout type timeout_close = setTimeout(dialog.close, delay) }) // if filtering, check focus changed to comboboxes and prevent closing @@ -7005,7 +6944,7 @@ export class LGraphCanvas implements CustomEventDispatcher that.search_box = dialog let first: string | null = null - let timeout: number | null = null + let timeout: ReturnType | null = null let selected: ChildNode | null = null const maybeInput = dialog.querySelector('input') @@ -7039,7 +6978,6 @@ export class LGraphCanvas implements CustomEventDispatcher if (timeout) { clearInterval(timeout) } - // @ts-expect-error - setTimeout type timeout = setTimeout(refreshHelper, 10) return } @@ -7314,9 +7252,7 @@ export class LGraphCanvas implements CustomEventDispatcher options.show_general_after_typefiltered && (sIn.value || sOut.value) ) { - // FIXME: Undeclared variable again - // @ts-expect-error Variable declared without type annotation - filtered_extra = [] + const filtered_extra: string[] = [] for (const i in LiteGraph.registered_node_types) { if ( inner_test_filter(i, { @@ -7324,11 +7260,9 @@ export class LGraphCanvas implements CustomEventDispatcher outTypeOverride: sOut && sOut.value ? '*' : false }) ) { - // @ts-expect-error Variable declared without type annotation filtered_extra.push(i) } } - // @ts-expect-error Variable declared without type annotation for (const extraItem of filtered_extra) { addResult(extraItem, 'generic_type') if ( @@ -7345,14 +7279,11 @@ export class LGraphCanvas implements CustomEventDispatcher helper.childNodes.length == 0 && options.show_general_if_none_on_typefilter ) { - // @ts-expect-error Variable declared without type annotation - filtered_extra = [] + const filtered_extra: string[] = [] for (const i in LiteGraph.registered_node_types) { if (inner_test_filter(i, { skipFilter: true })) - // @ts-expect-error Variable declared without type annotation filtered_extra.push(i) } - // @ts-expect-error Variable declared without type annotation for (const extraItem of filtered_extra) { addResult(extraItem, 'not_in_filter') if ( @@ -7647,13 +7578,12 @@ export class LGraphCanvas implements CustomEventDispatcher } } - let dialogCloseTimer: number + let dialogCloseTimer: ReturnType | undefined let prevent_timeout = 0 dialog.addEventListener('mouseleave', function () { if (prevent_timeout) return if (!dialog.is_modified && LiteGraph.dialog_close_on_mouse_leave) { - // @ts-expect-error - setTimeout type dialogCloseTimer = setTimeout( dialog.close, LiteGraph.dialog_close_on_mouse_leave_delay @@ -7687,7 +7617,6 @@ export class LGraphCanvas implements CustomEventDispatcher createPanel(title: string, options: ICreatePanelOptions) { options = options || {} - const ref_window = options.window || window // TODO: any kludge const root: any = document.createElement('div') root.className = 'litegraph dialog' @@ -7865,16 +7794,12 @@ export class LGraphCanvas implements CustomEventDispatcher innerChange(propname, v) return false } - new LiteGraph.ContextMenu( - values, - { - event, - className: 'dark', - callback: inner_clicked - }, - // @ts-expect-error ref_window parameter unused in ContextMenu constructor - ref_window - ) + new LiteGraph.ContextMenu(values, { + event, + className: 'dark', + // @ts-expect-error fixme ts strict error - callback signature mismatch + callback: inner_clicked + }) }) } @@ -8194,14 +8119,10 @@ export class LGraphCanvas implements CustomEventDispatcher { content: 'Properties Panel', callback: function ( - // @ts-expect-error - unused parameter - item: any, - // @ts-expect-error - unused parameter - options: any, - // @ts-expect-error - unused parameter - e: any, - // @ts-expect-error - unused parameter - menu: any, + _item: any, + _options: any, + _e: any, + _menu: any, node: LGraphNode ) { LGraphCanvas.active_canvas.showShowNodePanel(node) @@ -8312,9 +8233,6 @@ export class LGraphCanvas implements CustomEventDispatcher node: LGraphNode | undefined, event: CanvasPointerEvent ): void { - const canvas = LGraphCanvas.active_canvas - const ref_window = canvas.getCanvasWindow() - // TODO: Remove type kludge let menu_info: (IContextMenuValue | string | null)[] const options: IContextMenuOptions = { @@ -8428,8 +8346,7 @@ export class LGraphCanvas implements CustomEventDispatcher // show menu if (!menu_info) return - // @ts-expect-error Remove param ref_window - unused - new LiteGraph.ContextMenu(menu_info, options, ref_window) + new LiteGraph.ContextMenu(menu_info, options) const createDialog = (options: IDialogOptions) => this.createDialog( diff --git a/src/lib/litegraph/src/LGraphNode.test.ts b/src/lib/litegraph/src/LGraphNode.test.ts index 6451e7dfe..98ef533f6 100644 --- a/src/lib/litegraph/src/LGraphNode.test.ts +++ b/src/lib/litegraph/src/LGraphNode.test.ts @@ -38,7 +38,7 @@ describe('LGraphNode', () => { beforeEach(() => { origLiteGraph = Object.assign({}, LiteGraph) - // @ts-expect-error TODO: Fix after merge - Classes property not in type + // @ts-expect-error Intended: Force remove an otherwise readonly non-optional property delete origLiteGraph.Classes Object.assign(LiteGraph, { diff --git a/src/lib/litegraph/src/LGraphNode.titleButtons.test.ts b/src/lib/litegraph/src/LGraphNode.titleButtons.test.ts index 1c645cfd9..9d2a45992 100644 --- a/src/lib/litegraph/src/LGraphNode.titleButtons.test.ts +++ b/src/lib/litegraph/src/LGraphNode.titleButtons.test.ts @@ -35,11 +35,10 @@ describe('LGraphNode Title Buttons', () => { expect(node.title_buttons[2]).toBe(button3) }) - it('should create buttons with default options', () => { + it('should create buttons with minimal options', () => { const node = new LGraphNode('Test Node') - // @ts-expect-error TODO: Fix after merge - addTitleButton type issues - const button = node.addTitleButton({}) + const button = node.addTitleButton({ text: '' }) expect(button).toBeInstanceOf(LGraphButton) expect(button.name).toBeUndefined() @@ -55,9 +54,7 @@ describe('LGraphNode Title Buttons', () => { const button = node.addTitleButton({ name: 'close_button', - text: 'X', - // @ts-expect-error TODO: Fix after merge - visible property not defined in type - visible: true + text: 'X' }) // Mock button methods @@ -112,9 +109,7 @@ describe('LGraphNode Title Buttons', () => { const button = node.addTitleButton({ name: 'test_button', - text: 'T', - // @ts-expect-error TODO: Fix after merge - visible property not defined in type - visible: true + text: 'T' }) button.getWidth = vi.fn().mockReturnValue(20) @@ -164,16 +159,12 @@ describe('LGraphNode Title Buttons', () => { const button1 = node.addTitleButton({ name: 'button1', - text: 'A', - // @ts-expect-error TODO: Fix after merge - visible property not defined in type - visible: true + text: 'A' }) const button2 = node.addTitleButton({ name: 'button2', - text: 'B', - // @ts-expect-error TODO: Fix after merge - visible property not defined in type - visible: true + text: 'B' }) // Mock button methods @@ -297,8 +288,7 @@ describe('LGraphNode Title Buttons', () => { describe('onTitleButtonClick', () => { it('should dispatch litegraph:node-title-button-clicked event', () => { const node = new LGraphNode('Test Node') - // @ts-expect-error TODO: Fix after merge - LGraphButton constructor type issues - const button = new LGraphButton({ name: 'test_button' }) + const button = new LGraphButton({ name: 'test_button', text: 'X' }) const canvas = { dispatch: vi.fn() diff --git a/src/lib/litegraph/src/LGraphNode.ts b/src/lib/litegraph/src/LGraphNode.ts index 036bc5660..27559e021 100644 --- a/src/lib/litegraph/src/LGraphNode.ts +++ b/src/lib/litegraph/src/LGraphNode.ts @@ -679,7 +679,12 @@ export class LGraphNode this: LGraphNode, entries: (IContextMenuValue | null)[] ): (IContextMenuValue | null)[] - onMouseUp?(this: LGraphNode, e: CanvasPointerEvent, pos: Point): void + onMouseUp?( + this: LGraphNode, + e: CanvasPointerEvent, + pos: Point, + canvas: LGraphCanvas + ): void onMouseEnter?(this: LGraphNode, e: CanvasPointerEvent): void /** Blocks drag if return value is truthy. @param pos Offset from {@link LGraphNode.pos}. */ onMouseDown?( @@ -2769,8 +2774,7 @@ export class LGraphNode !LiteGraph.allow_multi_output_for_events ) { graph.beforeChange() - // @ts-expect-error Unused param - this.disconnectOutput(slot, false, { doProcessChange: false }) + this.disconnectOutput(slot) } } diff --git a/src/lib/litegraph/src/__fixtures__/assets/testGraphs.ts b/src/lib/litegraph/src/__fixtures__/assets/testGraphs.ts index ffed09e6b..03a3a1260 100644 --- a/src/lib/litegraph/src/__fixtures__/assets/testGraphs.ts +++ b/src/lib/litegraph/src/__fixtures__/assets/testGraphs.ts @@ -1,5 +1,6 @@ import type { ISerialisedGraph, + ISerialisedNode, SerialisableGraph } from '@/lib/litegraph/src/litegraph' @@ -19,12 +20,7 @@ export const oldSchemaGraph: ISerialisedGraph = { title: 'A group to test with' } ], - nodes: [ - // @ts-expect-error TODO: Fix after merge - missing required properties for test - { - id: 1 - } - ], + nodes: [{ id: 1 } as Partial as ISerialisedNode], links: [] } @@ -65,11 +61,7 @@ export const basicSerialisableGraph: SerialisableGraph = { } ], nodes: [ - // @ts-expect-error TODO: Fix after merge - missing required properties for test - { - id: 1, - type: 'mustBeSet' - } + { id: 1, type: 'mustBeSet' } as Partial as ISerialisedNode ], links: [] } diff --git a/src/lib/litegraph/src/interfaces.ts b/src/lib/litegraph/src/interfaces.ts index 67f1c3def..0983770a1 100644 --- a/src/lib/litegraph/src/interfaces.ts +++ b/src/lib/litegraph/src/interfaces.ts @@ -338,6 +338,7 @@ export interface INodeFlags { */ export interface IWidgetLocator { name: string + type?: string } export interface INodeInputSlot extends INodeSlot { diff --git a/src/lib/litegraph/src/node/NodeSlot.test.ts b/src/lib/litegraph/src/node/NodeSlot.test.ts index 15215cbf0..6971736fc 100644 --- a/src/lib/litegraph/src/node/NodeSlot.test.ts +++ b/src/lib/litegraph/src/node/NodeSlot.test.ts @@ -8,16 +8,19 @@ import { inputAsSerialisable, outputAsSerialisable } from '@/lib/litegraph/src/litegraph' +import type { ReadOnlyRect } from '@/lib/litegraph/src/interfaces' + +const boundingRect: ReadOnlyRect = [0, 0, 10, 10] describe('NodeSlot', () => { describe('inputAsSerialisable', () => { it('removes _data from serialized slot', () => { - // @ts-expect-error Missing boundingRect property for test const slot: INodeOutputSlot = { _data: 'test data', name: 'test-id', type: 'STRING', - links: [] + links: [], + boundingRect } // @ts-expect-error Argument type mismatch for test const serialized = outputAsSerialisable(slot) @@ -25,20 +28,14 @@ describe('NodeSlot', () => { }) it('removes pos from widget input slots', () => { + // Minimal slot for serialization test - boundingRect is calculated at runtime, not serialized const widgetInputSlot: INodeInputSlot = { name: 'test-id', pos: [10, 20], type: 'STRING', link: null, - widget: { - name: 'test-widget', - // @ts-expect-error TODO: Fix after merge - type property not in IWidgetLocator - type: 'combo', - value: 'test-value-1', - options: { - values: ['test-value-1', 'test-value-2'] - } - } + widget: { name: 'test-widget', type: 'combo' }, + boundingRect } const serialized = inputAsSerialisable(widgetInputSlot) @@ -46,30 +43,27 @@ describe('NodeSlot', () => { }) it('preserves pos for non-widget input slots', () => { - // @ts-expect-error TODO: Fix after merge - missing boundingRect property for test const normalSlot: INodeInputSlot = { name: 'test-id', type: 'STRING', pos: [10, 20], - link: null + link: null, + boundingRect } const serialized = inputAsSerialisable(normalSlot) expect(serialized).toHaveProperty('pos') }) it('preserves only widget name during serialization', () => { + // Extra widget properties simulate real data that should be stripped during serialization const widgetInputSlot: INodeInputSlot = { name: 'test-id', type: 'STRING', link: null, + boundingRect, widget: { name: 'test-widget', - // @ts-expect-error TODO: Fix after merge - type property not in IWidgetLocator - type: 'combo', - value: 'test-value-1', - options: { - values: ['test-value-1', 'test-value-2'] - } + type: 'combo' } } diff --git a/src/lib/litegraph/src/subgraph/ExecutableNodeDTO.test.ts b/src/lib/litegraph/src/subgraph/ExecutableNodeDTO.test.ts index 003fa59e1..c475bb3aa 100644 --- a/src/lib/litegraph/src/subgraph/ExecutableNodeDTO.test.ts +++ b/src/lib/litegraph/src/subgraph/ExecutableNodeDTO.test.ts @@ -86,10 +86,8 @@ describe.skip('ExecutableNodeDTO Creation', () => { expect(dto.applyToGraph).toBeDefined() - // Test that wrapper calls original method const args = ['arg1', 'arg2'] - // @ts-expect-error TODO: Fix after merge - applyToGraph expects different arguments - dto.applyToGraph!(args[0], args[1]) + ;(dto.applyToGraph as (...args: unknown[]) => void)(args[0], args[1]) expect(mockApplyToGraph).toHaveBeenCalledWith(args[0], args[1]) }) diff --git a/src/lib/litegraph/src/subgraph/Subgraph.test.ts b/src/lib/litegraph/src/subgraph/Subgraph.test.ts index 4266a6073..ecd939654 100644 --- a/src/lib/litegraph/src/subgraph/Subgraph.test.ts +++ b/src/lib/litegraph/src/subgraph/Subgraph.test.ts @@ -185,14 +185,10 @@ describe.skip('Subgraph Serialization', () => { expect(serialized.inputs).toHaveLength(1) expect(serialized.outputs).toHaveLength(1) - // @ts-expect-error TODO: Fix after merge - serialized.inputs possibly undefined - expect(serialized.inputs[0].name).toBe('input') - // @ts-expect-error TODO: Fix after merge - serialized.inputs possibly undefined - expect(serialized.inputs[0].type).toBe('number') - // @ts-expect-error TODO: Fix after merge - serialized.outputs possibly undefined - expect(serialized.outputs[0].name).toBe('output') - // @ts-expect-error TODO: Fix after merge - serialized.outputs possibly undefined - expect(serialized.outputs[0].type).toBe('number') + expect(serialized.inputs![0].name).toBe('input') + expect(serialized.inputs![0].type).toBe('number') + expect(serialized.outputs![0].name).toBe('output') + expect(serialized.outputs![0].type).toBe('number') } ) diff --git a/src/lib/litegraph/src/subgraph/SubgraphEdgeCases.test.ts b/src/lib/litegraph/src/subgraph/SubgraphEdgeCases.test.ts index 3251a4d88..b161467e2 100644 --- a/src/lib/litegraph/src/subgraph/SubgraphEdgeCases.test.ts +++ b/src/lib/litegraph/src/subgraph/SubgraphEdgeCases.test.ts @@ -350,8 +350,7 @@ describe.skip('SubgraphEdgeCases - Performance and Scale', () => { const subgraphNode = createTestSubgraphNode(subgraph) // Simulate concurrent operations - // @ts-expect-error TODO: Fix after merge - operations implicitly has any[] type - const operations = [] + const operations: Array<() => void> = [] for (let i = 0; i < 20; i++) { operations.push( () => { @@ -371,7 +370,6 @@ describe.skip('SubgraphEdgeCases - Performance and Scale', () => { // Execute all operations - should not crash expect(() => { - // @ts-expect-error TODO: Fix after merge - operations implicitly has any[] type for (const op of operations) op() }).not.toThrow() }) diff --git a/src/lib/litegraph/src/subgraph/SubgraphEvents.test.ts b/src/lib/litegraph/src/subgraph/SubgraphEvents.test.ts index ade35e919..ce4fe45c8 100644 --- a/src/lib/litegraph/src/subgraph/SubgraphEvents.test.ts +++ b/src/lib/litegraph/src/subgraph/SubgraphEvents.test.ts @@ -22,7 +22,6 @@ describe.skip('SubgraphEvents - Event Payload Verification', () => { }) }) - // @ts-expect-error TODO: Fix after merge - detail is of type unknown expect(addedEvents[0].detail.input).toBe(input) } ) @@ -44,7 +43,6 @@ describe.skip('SubgraphEvents - Event Payload Verification', () => { }) }) - // @ts-expect-error TODO: Fix after merge - detail is of type unknown expect(addedEvents[0].detail.output).toBe(output) } ) @@ -71,7 +69,6 @@ describe.skip('SubgraphEvents - Event Payload Verification', () => { index: 0 }) - // @ts-expect-error TODO: Fix after merge - detail is of type unknown expect(removingEvents[0].detail.input).toBe(input) } ) @@ -98,7 +95,6 @@ describe.skip('SubgraphEvents - Event Payload Verification', () => { index: 0 }) - // @ts-expect-error TODO: Fix after merge - detail is of type unknown expect(removingEvents[0].detail.output).toBe(output) } ) @@ -126,7 +122,6 @@ describe.skip('SubgraphEvents - Event Payload Verification', () => { newName: 'new_name' }) - // @ts-expect-error TODO: Fix after merge - detail is of type unknown expect(renamingEvents[0].detail.input).toBe(input) // Verify the label was updated after the event (renameInput sets label, not name) @@ -160,7 +155,6 @@ describe.skip('SubgraphEvents - Event Payload Verification', () => { newName: 'new_name' }) - // @ts-expect-error TODO: Fix after merge - detail is of type unknown expect(renamingEvents[0].detail.output).toBe(output) // Verify the label was updated after the event diff --git a/src/lib/litegraph/src/subgraph/SubgraphIO.test.ts b/src/lib/litegraph/src/subgraph/SubgraphIO.test.ts index c3fa79970..04c6757b6 100644 --- a/src/lib/litegraph/src/subgraph/SubgraphIO.test.ts +++ b/src/lib/litegraph/src/subgraph/SubgraphIO.test.ts @@ -28,8 +28,7 @@ describe('SubgraphIO - Input Slot Dual-Nature Behavior', () => { }).not.toThrow() expect( - // @ts-expect-error TODO: Fix after merge - link can be null - externalNode.outputs[0].links?.includes(subgraphNode.inputs[0].link) + externalNode.outputs[0].links?.includes(subgraphNode.inputs[0].link!) ).toBe(true) expect(subgraphNode.inputs[0].link).not.toBe(null) } @@ -47,10 +46,8 @@ describe('SubgraphIO - Input Slot Dual-Nature Behavior', () => { expect(simpleSubgraph.inputs.length).toBe(initialInputCount + 1) // The empty slot should be configurable - const emptyInput = simpleSubgraph.inputs.at(-1) - // @ts-expect-error TODO: Fix after merge - emptyInput possibly undefined + const emptyInput = simpleSubgraph.inputs.at(-1)! expect(emptyInput.name).toBe('') - // @ts-expect-error TODO: Fix after merge - emptyInput possibly undefined expect(emptyInput.type).toBe('*') } ) @@ -149,8 +146,7 @@ describe('SubgraphIO - Output Slot Dual-Nature Behavior', () => { }).not.toThrow() expect( - // @ts-expect-error TODO: Fix after merge - link can be null - subgraphNode.outputs[0].links?.includes(externalNode.inputs[0].link) + subgraphNode.outputs[0].links?.includes(externalNode.inputs[0].link!) ).toBe(true) expect(externalNode.inputs[0].link).not.toBe(null) } @@ -168,10 +164,8 @@ describe('SubgraphIO - Output Slot Dual-Nature Behavior', () => { expect(simpleSubgraph.outputs.length).toBe(initialOutputCount + 1) // The empty slot should be configurable - const emptyOutput = simpleSubgraph.outputs.at(-1) - // @ts-expect-error TODO: Fix after merge - emptyOutput possibly undefined + const emptyOutput = simpleSubgraph.outputs.at(-1)! expect(emptyOutput.name).toBe('') - // @ts-expect-error TODO: Fix after merge - emptyOutput possibly undefined expect(emptyOutput.type).toBe('*') } ) @@ -454,15 +448,11 @@ describe('SubgraphIO - Empty Slot Connection', () => { // 3. A link should be established inside the subgraph expect(internalNode.inputs[0].link).not.toBe(null) - const link = subgraph.links.get(internalNode.inputs[0].link!) + const link = subgraph.links.get(internalNode.inputs[0].link!)! expect(link).toBeDefined() - // @ts-expect-error TODO: Fix after merge - link possibly undefined expect(link.target_id).toBe(internalNode.id) - // @ts-expect-error TODO: Fix after merge - link possibly undefined expect(link.target_slot).toBe(0) - // @ts-expect-error TODO: Fix after merge - link possibly undefined expect(link.origin_id).toBe(subgraph.inputNode.id) - // @ts-expect-error TODO: Fix after merge - link possibly undefined expect(link.origin_slot).toBe(1) // Should be the second slot } ) diff --git a/src/lib/litegraph/src/subgraph/SubgraphMemory.test.ts b/src/lib/litegraph/src/subgraph/SubgraphMemory.test.ts index 6a4e662bf..7b936392a 100644 --- a/src/lib/litegraph/src/subgraph/SubgraphMemory.test.ts +++ b/src/lib/litegraph/src/subgraph/SubgraphMemory.test.ts @@ -2,6 +2,7 @@ import { describe, expect, it, vi } from 'vitest' import { LGraph } from '@/lib/litegraph/src/litegraph' +import type { IWidget } from '@/lib/litegraph/src/types/widgets' import { subgraphTest } from './__fixtures__/subgraphFixtures' import { @@ -72,10 +73,10 @@ describe.skip('SubgraphNode Memory Management', () => { size: [200, 100], inputs: [], outputs: [], - // @ts-expect-error TODO: Fix after merge - properties not in ExportedSubgraphInstance properties: {}, flags: {}, - mode: 0 + mode: 0, + order: 0 }) } @@ -93,12 +94,13 @@ describe.skip('SubgraphNode Memory Management', () => { }) const subgraphNode = createTestSubgraphNode(subgraph) - // Simulate widget promotion scenario const input = subgraphNode.inputs[0] const mockWidget = { type: 'number', name: 'promoted_widget', value: 123, + options: {}, + y: 0, draw: vi.fn(), mouse: vi.fn(), computeSize: vi.fn(), @@ -107,21 +109,16 @@ describe.skip('SubgraphNode Memory Management', () => { name: 'promoted_widget', value: 123 }) - } + } as Partial as IWidget - // Simulate widget promotion - // @ts-expect-error TODO: Fix after merge - mockWidget type mismatch input._widget = mockWidget input.widget = { name: 'promoted_widget' } - // @ts-expect-error TODO: Fix after merge - mockWidget type mismatch subgraphNode.widgets.push(mockWidget) expect(input._widget).toBe(mockWidget) expect(input.widget).toBeDefined() expect(subgraphNode.widgets).toContain(mockWidget) - // Remove widget (this should clean up references) - // @ts-expect-error TODO: Fix after merge - mockWidget type mismatch subgraphNode.removeWidget(mockWidget) // Widget should be removed from array @@ -146,10 +143,10 @@ describe.skip('SubgraphNode Memory Management', () => { size: [200, 100], inputs: [], outputs: [], - // @ts-expect-error TODO: Fix after merge - properties not in ExportedSubgraphInstance properties: {}, flags: {}, - mode: 0 + mode: 0, + order: 0 }) } @@ -328,17 +325,26 @@ describe.skip('SubgraphMemory - Widget Reference Management', () => { const initialWidgetCount = subgraphNode.widgets?.length || 0 - // Add mock widgets - const widget1 = { type: 'number', value: 1, name: 'widget1' } - const widget2 = { type: 'string', value: 'test', name: 'widget2' } + const widget1 = { + type: 'number', + value: 1, + name: 'widget1', + options: {}, + y: 0 + } as Partial as IWidget + const widget2 = { + type: 'string', + value: 'test', + name: 'widget2', + options: {}, + y: 0 + } as Partial as IWidget if (subgraphNode.widgets) { - // @ts-expect-error TODO: Fix after merge - widget type mismatch subgraphNode.widgets.push(widget1, widget2) expect(subgraphNode.widgets.length).toBe(initialWidgetCount + 2) } - // Remove widgets if (subgraphNode.widgets) { subgraphNode.widgets.length = initialWidgetCount expect(subgraphNode.widgets.length).toBe(initialWidgetCount) diff --git a/src/lib/litegraph/src/subgraph/SubgraphNode.test.ts b/src/lib/litegraph/src/subgraph/SubgraphNode.test.ts index e82e03149..96e2e5dd3 100644 --- a/src/lib/litegraph/src/subgraph/SubgraphNode.test.ts +++ b/src/lib/litegraph/src/subgraph/SubgraphNode.test.ts @@ -7,6 +7,7 @@ */ import { describe, expect, it, vi } from 'vitest' +import type { SubgraphNode } from '@/lib/litegraph/src/litegraph' import { LGraph, Subgraph } from '@/lib/litegraph/src/litegraph' import { subgraphTest } from './__fixtures__/subgraphFixtures' @@ -210,10 +211,10 @@ describe.skip('SubgraphNode Lifecycle', () => { size: [180, 100], inputs: [], outputs: [], - // @ts-expect-error TODO: Fix after merge - properties not in ExportedSubgraphInstance properties: {}, flags: {}, - mode: 0 + mode: 0, + order: 0 }) // Should reflect updated subgraph structure @@ -542,8 +543,6 @@ describe.skip('SubgraphNode Cleanup', () => { const rootGraph = new LGraph() const subgraph = createTestSubgraph() - // Add and remove nodes multiple times - // @ts-expect-error TODO: Fix after merge - SubgraphNode should be Subgraph const removedNodes: SubgraphNode[] = [] for (let i = 0; i < 3; i++) { const node = createTestSubgraphNode(subgraph) diff --git a/src/lib/litegraph/src/subgraph/SubgraphWidgetPromotion.test.ts b/src/lib/litegraph/src/subgraph/SubgraphWidgetPromotion.test.ts index d938b300a..d47ca186d 100644 --- a/src/lib/litegraph/src/subgraph/SubgraphWidgetPromotion.test.ts +++ b/src/lib/litegraph/src/subgraph/SubgraphWidgetPromotion.test.ts @@ -134,9 +134,7 @@ describe.skip('SubgraphWidgetPromotion', () => { // Check event was fired const promotedEvents = eventCapture.getEventsByType('widget-promoted') expect(promotedEvents).toHaveLength(1) - // @ts-expect-error Object is of type 'unknown' expect(promotedEvents[0].detail.widget).toBeDefined() - // @ts-expect-error Object is of type 'unknown' expect(promotedEvents[0].detail.subgraphNode).toBe(subgraphNode) eventCapture.cleanup() @@ -161,9 +159,7 @@ describe.skip('SubgraphWidgetPromotion', () => { // Check event was fired const demotedEvents = eventCapture.getEventsByType('widget-demoted') expect(demotedEvents).toHaveLength(1) - // @ts-expect-error Object is of type 'unknown' expect(demotedEvents[0].detail.widget).toBeDefined() - // @ts-expect-error Object is of type 'unknown' expect(demotedEvents[0].detail.subgraphNode).toBe(subgraphNode) // Widget should be removed diff --git a/src/lib/litegraph/src/subgraph/__fixtures__/subgraphFixtures.ts b/src/lib/litegraph/src/subgraph/__fixtures__/subgraphFixtures.ts index 6f88d1c8f..25fab065e 100644 --- a/src/lib/litegraph/src/subgraph/__fixtures__/subgraphFixtures.ts +++ b/src/lib/litegraph/src/subgraph/__fixtures__/subgraphFixtures.ts @@ -8,6 +8,7 @@ */ import type { Subgraph } from '@/lib/litegraph/src/litegraph' import { LGraph } from '@/lib/litegraph/src/litegraph' +import type { SubgraphEventMap } from '@/lib/litegraph/src/infrastructure/SubgraphEventMap' import type { SubgraphNode } from '@/lib/litegraph/src/subgraph/SubgraphNode' import { test } from '../../__fixtures__/testExtensions' @@ -17,6 +18,7 @@ import { createTestSubgraph, createTestSubgraphNode } from './subgraphHelpers' +import type { EventCapture } from './subgraphHelpers' interface SubgraphFixtures { /** A minimal subgraph with no inputs, outputs, or nodes */ @@ -41,7 +43,7 @@ interface SubgraphFixtures { /** Event capture system for testing subgraph events */ eventCapture: { subgraph: Subgraph - capture: ReturnType + capture: EventCapture } } @@ -59,9 +61,7 @@ interface SubgraphFixtures { * ``` */ export const subgraphTest = test.extend({ - // @ts-expect-error TODO: Fix after merge - fixture use parameter type - - emptySubgraph: async ({}, use: (value: unknown) => Promise) => { + emptySubgraph: async ({}, use) => { const subgraph = createTestSubgraph({ name: 'Empty Test Subgraph', inputCount: 0, @@ -72,9 +72,7 @@ export const subgraphTest = test.extend({ await use(subgraph) }, - // @ts-expect-error TODO: Fix after merge - fixture use parameter type - - simpleSubgraph: async ({}, use: (value: unknown) => Promise) => { + simpleSubgraph: async ({}, use) => { const subgraph = createTestSubgraph({ name: 'Simple Test Subgraph', inputs: [{ name: 'input', type: 'number' }], @@ -85,9 +83,7 @@ export const subgraphTest = test.extend({ await use(subgraph) }, - // @ts-expect-error TODO: Fix after merge - fixture use parameter type - - complexSubgraph: async ({}, use: (value: unknown) => Promise) => { + complexSubgraph: async ({}, use) => { const subgraph = createTestSubgraph({ name: 'Complex Test Subgraph', inputs: [ @@ -105,9 +101,7 @@ export const subgraphTest = test.extend({ await use(subgraph) }, - // @ts-expect-error TODO: Fix after merge - fixture use parameter type - - nestedSubgraph: async ({}, use: (value: unknown) => Promise) => { + nestedSubgraph: async ({}, use) => { const nested = createNestedSubgraphs({ depth: 3, nodesPerLevel: 2, @@ -118,10 +112,7 @@ export const subgraphTest = test.extend({ await use(nested) }, - // @ts-expect-error TODO: Fix after merge - fixture use parameter type - - subgraphWithNode: async ({}, use: (value: unknown) => Promise) => { - // Create the subgraph definition + subgraphWithNode: async ({}, use) => { const subgraph = createTestSubgraph({ name: 'Subgraph With Node', inputs: [{ name: 'input', type: '*' }], @@ -129,14 +120,12 @@ export const subgraphTest = test.extend({ nodeCount: 1 }) - // Create the parent graph and subgraph node instance const parentGraph = new LGraph() const subgraphNode = createTestSubgraphNode(subgraph, { pos: [200, 200], size: [180, 80] }) - // Add the subgraph node to the parent graph parentGraph.add(subgraphNode) await use({ @@ -146,15 +135,12 @@ export const subgraphTest = test.extend({ }) }, - // @ts-expect-error TODO: Fix after merge - fixture use parameter type - - eventCapture: async ({}, use: (value: unknown) => Promise) => { + eventCapture: async ({}, use) => { const subgraph = createTestSubgraph({ name: 'Event Test Subgraph' }) - // Set up event capture for all subgraph events - const capture = createEventCapture(subgraph.events, [ + const capture = createEventCapture(subgraph.events, [ 'adding-input', 'input-added', 'removing-input', @@ -167,7 +153,6 @@ export const subgraphTest = test.extend({ await use({ subgraph, capture }) - // Cleanup event listeners capture.cleanup() } }) diff --git a/src/lib/litegraph/src/subgraph/__fixtures__/subgraphHelpers.ts b/src/lib/litegraph/src/subgraph/__fixtures__/subgraphHelpers.ts index 736f979d3..5672dc685 100644 --- a/src/lib/litegraph/src/subgraph/__fixtures__/subgraphHelpers.ts +++ b/src/lib/litegraph/src/subgraph/__fixtures__/subgraphHelpers.ts @@ -55,6 +55,16 @@ interface CapturedEvent { timestamp: number } +/** Return type for createEventCapture with typed getEventsByType */ +export interface EventCapture { + events: CapturedEvent[] + clear: () => void + cleanup: () => void + getEventsByType: ( + type: K + ) => CapturedEvent[] +} + /** * Creates a test subgraph with specified inputs, outputs, and nodes. * This is the primary function for creating subgraphs in tests. @@ -91,34 +101,35 @@ export function createTestSubgraph( } const rootGraph = new LGraph() - // Create the base subgraph data const subgraphData: ExportedSubgraph = { - // Basic graph properties version: 1, + revision: 0, + state: { + lastNodeId: 0, + lastLinkId: 0, + lastGroupId: 0, + lastRerouteId: 0 + }, nodes: [], - // @ts-expect-error TODO: Fix after merge - links type mismatch - links: {}, + links: [], groups: [], config: {}, definitions: { subgraphs: [] }, - // Subgraph-specific properties id: options.id || createUuidv4(), name: options.name || 'Test Subgraph', - // IO Nodes (required for subgraph functionality) inputNode: { - id: -10, // SUBGRAPH_INPUT_ID - bounding: [10, 100, 150, 126], // [x, y, width, height] + id: -10, + bounding: [10, 100, 150, 126], pinned: false }, outputNode: { - id: -20, // SUBGRAPH_OUTPUT_ID - bounding: [400, 100, 140, 126], // [x, y, width, height] + id: -20, + bounding: [400, 100, 140, 126], pinned: false }, - // IO definitions - will be populated by addInput/addOutput calls inputs: [], outputs: [], widgets: [] @@ -127,11 +138,9 @@ export function createTestSubgraph( // Create the subgraph const subgraph = new Subgraph(rootGraph, subgraphData) - // Add requested inputs if (options.inputs) { for (const input of options.inputs) { - // @ts-expect-error TODO: Fix after merge - addInput parameter types - subgraph.addInput(input.name, input.type) + subgraph.addInput(input.name, String(input.type)) } } else if (options.inputCount) { for (let i = 0; i < options.inputCount; i++) { @@ -139,11 +148,9 @@ export function createTestSubgraph( } } - // Add requested outputs if (options.outputs) { for (const output of options.outputs) { - // @ts-expect-error TODO: Fix after merge - addOutput parameter types - subgraph.addOutput(output.name, output.type) + subgraph.addOutput(output.name, String(output.type)) } } else if (options.outputCount) { for (let i = 0; i < options.outputCount; i++) { @@ -193,10 +200,10 @@ export function createTestSubgraphNode( size: options.size || [200, 100], inputs: [], outputs: [], - // @ts-expect-error TODO: Fix after merge - properties type mismatch properties: {}, flags: {}, - mode: 0 + mode: 0, + order: 0 } return new SubgraphNode(parentGraph, subgraph, instanceData) @@ -237,18 +244,11 @@ export function createNestedSubgraphs(options: NestedSubgraphOptions = {}) { subgraphs.push(subgraph) - // Create instance in parent const subgraphNode = createTestSubgraphNode(subgraph, { pos: [100 + level * 200, 100] }) - if (currentParent instanceof LGraph) { - currentParent.add(subgraphNode) - } else { - // @ts-expect-error TODO: Fix after merge - add method parameter types - currentParent.add(subgraphNode) - } - + currentParent.add(subgraphNode) subgraphNodes.push(subgraphNode) // Next level will be nested inside this subgraph @@ -353,9 +353,15 @@ export function createTestSubgraphData( ): ExportedSubgraph { return { version: 1, + revision: 0, + state: { + lastNodeId: 0, + lastLinkId: 0, + lastGroupId: 0, + lastRerouteId: 0 + }, nodes: [], - // @ts-expect-error TODO: Fix after merge - links type mismatch - links: {}, + links: [], groups: [], config: {}, definitions: { subgraphs: [] }, @@ -386,13 +392,13 @@ export function createTestSubgraphData( * Creates an event capture system for testing event sequences. * @param eventTarget The event target to monitor * @param eventTypes Array of event types to capture - * @returns Object with captured events and helper methods + * @returns Object with captured events and typed getEventsByType method */ -export function createEventCapture( +export function createEventCapture( eventTarget: EventTarget, - eventTypes: string[] -) { - const capturedEvents: CapturedEvent[] = [] + eventTypes: Array +): EventCapture { + const capturedEvents: CapturedEvent[] = [] const listeners: Array<() => void> = [] // Set up listeners for each event type @@ -400,7 +406,7 @@ export function createEventCapture( const listener = (event: Event) => { capturedEvents.push({ type: eventType, - detail: (event as CustomEvent).detail, + detail: (event as CustomEvent).detail, timestamp: Date.now() }) } @@ -418,7 +424,9 @@ export function createEventCapture( // Remove all event listeners to prevent memory leaks for (const cleanup of listeners) cleanup() }, - getEventsByType: (type: string) => - capturedEvents.filter((e) => e.type === type) + getEventsByType: (type: K) => + capturedEvents.filter((e) => e.type === type) as CapturedEvent< + TEventMap[K] + >[] } } diff --git a/src/lib/litegraph/src/types/serialisation.ts b/src/lib/litegraph/src/types/serialisation.ts index 8a31e5652..c97293829 100644 --- a/src/lib/litegraph/src/types/serialisation.ts +++ b/src/lib/litegraph/src/types/serialisation.ts @@ -111,6 +111,8 @@ export interface ExportedSubgraphInstance extends NodeSubgraphSharedProps { * @see {@link ExportedSubgraph.subgraphs} */ type: UUID + /** Custom properties for this subgraph instance */ + properties?: Dictionary } /** diff --git a/src/lib/litegraph/src/widgets/ComboWidget.test.ts b/src/lib/litegraph/src/widgets/ComboWidget.test.ts index b1605906f..f080dbab7 100644 --- a/src/lib/litegraph/src/widgets/ComboWidget.test.ts +++ b/src/lib/litegraph/src/widgets/ComboWidget.test.ts @@ -463,7 +463,8 @@ describe('ComboWidget', () => { .mockImplementation(function (_values, options) { capturedCallback = options.callback }) - LiteGraph.ContextMenu = mockContextMenu + LiteGraph.ContextMenu = + mockContextMenu as unknown as typeof LiteGraph.ContextMenu const setValueSpy = vi.spyOn(widget, 'setValue') widget.onClick({ e: mockEvent, node, canvas: mockCanvas }) @@ -505,7 +506,8 @@ describe('ComboWidget', () => { .mockImplementation(function (_values, options) { capturedCallback = options.callback }) - LiteGraph.ContextMenu = mockContextMenu + LiteGraph.ContextMenu = + mockContextMenu as unknown as typeof LiteGraph.ContextMenu const setValueSpy = vi.spyOn(widget, 'setValue') widget.onClick({ e: mockEvent, node, canvas: mockCanvas }) @@ -766,8 +768,8 @@ describe('ComboWidget', () => { .mockImplementation(function () { this.addItem = mockAddItem }) - LiteGraph.ContextMenu = mockContextMenu - + LiteGraph.ContextMenu = + mockContextMenu as unknown as typeof LiteGraph.ContextMenu widget.onClick({ e: mockEvent, node, canvas: mockCanvas }) // Should show formatted labels in dropdown @@ -829,7 +831,8 @@ describe('ComboWidget', () => { capturedCallback = options.callback this.addItem = mockAddItem }) - LiteGraph.ContextMenu = mockContextMenu + LiteGraph.ContextMenu = + mockContextMenu as unknown as typeof LiteGraph.ContextMenu const setValueSpy = vi.spyOn(widget, 'setValue') widget.onClick({ e: mockEvent, node, canvas: mockCanvas }) @@ -882,7 +885,8 @@ describe('ComboWidget', () => { capturedCallback = options.callback this.addItem = mockAddItem }) - LiteGraph.ContextMenu = mockContextMenu + LiteGraph.ContextMenu = + mockContextMenu as unknown as typeof LiteGraph.ContextMenu widget.onClick({ e: mockEvent, node, canvas: mockCanvas }) @@ -960,7 +964,8 @@ describe('ComboWidget', () => { .mockImplementation(function () { this.addItem = mockAddItem }) - LiteGraph.ContextMenu = mockContextMenu + LiteGraph.ContextMenu = + mockContextMenu as unknown as typeof LiteGraph.ContextMenu widget.onClick({ e: mockEvent, node, canvas: mockCanvas }) @@ -1007,7 +1012,8 @@ describe('ComboWidget', () => { node.size = [200, 30] const mockContextMenu = vi.fn() - LiteGraph.ContextMenu = mockContextMenu + LiteGraph.ContextMenu = + mockContextMenu as unknown as typeof LiteGraph.ContextMenu widget.onClick({ e: mockEvent, node, canvas: mockCanvas }) diff --git a/src/platform/cloud/onboarding/auth.ts b/src/platform/cloud/onboarding/auth.ts index 75d183dc6..88399d251 100644 --- a/src/platform/cloud/onboarding/auth.ts +++ b/src/platform/cloud/onboarding/auth.ts @@ -127,53 +127,6 @@ export async function getSurveyCompletedStatus(): Promise { } } -// @ts-expect-error - Unused function kept for future use -async function postSurveyStatus(): Promise { - try { - const response = await api.fetchApi(`/settings/${ONBOARDING_SURVEY_KEY}`, { - method: 'POST', - headers: { - 'Content-Type': 'application/json' - }, - body: JSON.stringify({ [ONBOARDING_SURVEY_KEY]: undefined }) - }) - - if (!response.ok) { - const error = new Error( - `Failed to post survey status: ${response.statusText}` - ) - captureApiError( - error, - '/settings/{key}', - 'http_error', - response.status, - 'post_survey_status', - { - route_template: '/settings/{key}', - route_actual: `/settings/${ONBOARDING_SURVEY_KEY}` - } - ) - throw error - } - } catch (error) { - // Only capture network errors (not HTTP errors we already captured) - if (!isHttpError(error, 'Failed to post survey status:')) { - captureApiError( - error as Error, - '/settings/{key}', - 'network_error', - undefined, - 'post_survey_status', - { - route_template: '/settings/{key}', - route_actual: `/settings/${ONBOARDING_SURVEY_KEY}` - } - ) - } - throw error - } -} - export async function submitSurvey( survey: Record ): Promise {