From 35ddd998ece886c9fac3d52f1d8cdc8c97dbbb3c Mon Sep 17 00:00:00 2001 From: Johnpaul Date: Thu, 22 Jan 2026 22:28:43 +0100 Subject: [PATCH] refactor: remove any types from batch 14 test files (6 instances) Fixed 6 'as any' instances across 3 files: - LinkConnector.core.test.ts: Used Parameters utility type for method parameters - useSelectionState.test.ts: Used ReturnType for composable and filter returns - SubgraphNode.test.ts: Used SubgraphEventMap for event dispatch typing --- src/composables/graph/useSelectionState.test.ts | 7 +++++-- src/lib/litegraph/src/canvas/LinkConnector.core.test.ts | 8 ++++++-- src/lib/litegraph/src/subgraph/SubgraphNode.test.ts | 9 +++++---- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/composables/graph/useSelectionState.test.ts b/src/composables/graph/useSelectionState.test.ts index 7d521d743..e16c8f13f 100644 --- a/src/composables/graph/useSelectionState.test.ts +++ b/src/composables/graph/useSelectionState.test.ts @@ -168,7 +168,7 @@ describe('useSelectionState', () => { title: 'Node Library', type: 'custom', render: () => null - } as any) + } as unknown as ReturnType) // Setup mock utility functions vi.mocked(isLGraphNode).mockImplementation((item: unknown) => { @@ -180,7 +180,10 @@ describe('useSelectionState', () => { return typedNode?.type === 'ImageNode' }) vi.mocked(filterOutputNodes).mockImplementation( - (nodes: TestNode[]) => nodes.filter((n) => n.type === 'OutputNode') as any + (nodes: TestNode[]) => + nodes.filter((n) => n.type === 'OutputNode') as unknown as ReturnType< + typeof filterOutputNodes + > ) }) diff --git a/src/lib/litegraph/src/canvas/LinkConnector.core.test.ts b/src/lib/litegraph/src/canvas/LinkConnector.core.test.ts index 65b468940..1eb73ed60 100644 --- a/src/lib/litegraph/src/canvas/LinkConnector.core.test.ts +++ b/src/lib/litegraph/src/canvas/LinkConnector.core.test.ts @@ -136,7 +136,9 @@ describe('LinkConnector', () => { connector.state.connectingTo = 'input' expect(() => { - connector.moveInputLink(network, { link: 1 } as any) + connector.moveInputLink(network, { link: 1 } as unknown as Parameters< + typeof connector.moveInputLink + >[1]) }).toThrow('Already dragging links.') }) }) @@ -174,7 +176,9 @@ describe('LinkConnector', () => { connector.state.connectingTo = 'output' expect(() => { - connector.moveOutputLink(network, { links: [1] } as any) + connector.moveOutputLink(network, { + links: [1] + } as unknown as Parameters[1]) }).toThrow('Already dragging links.') }) }) diff --git a/src/lib/litegraph/src/subgraph/SubgraphNode.test.ts b/src/lib/litegraph/src/subgraph/SubgraphNode.test.ts index 96e2e5dd3..a83ad3522 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 { SubgraphEventMap } from '@/lib/litegraph/src/infrastructure/SubgraphEventMap' import type { SubgraphNode } from '@/lib/litegraph/src/litegraph' import { LGraph, Subgraph } from '@/lib/litegraph/src/litegraph' @@ -531,8 +532,8 @@ describe.skip('SubgraphNode Cleanup', () => { // Now trigger an event - only node1 should respond subgraph.events.dispatch('input-added', { - input: { name: 'test', type: 'number', id: 'test-id' } as any - }) + input: { name: 'test', type: 'number', id: 'test-id' } + } as unknown as SubgraphEventMap['input-added']) // Only node1 should have added an input expect(node1.inputs.length).toBe(1) // node1 responds @@ -558,8 +559,8 @@ describe.skip('SubgraphNode Cleanup', () => { // Trigger an event - no nodes should respond subgraph.events.dispatch('input-added', { - input: { name: 'test', type: 'number', id: 'test-id' } as any - }) + input: { name: 'test', type: 'number', id: 'test-id' } + } as unknown as SubgraphEventMap['input-added']) // Without cleanup: all 3 removed nodes would have added an input // With cleanup: no nodes should have added an input