From 9adfa9efc255100d0dd70e7120fdcafb47bf2ed9 Mon Sep 17 00:00:00 2001 From: Connor Byrne Date: Wed, 13 May 2026 18:27:47 -0700 Subject: [PATCH] fix(v2-tests): resolve type errors in BC pattern tests - Fix Size type usage (tuple [width, height] not object) - Fix entity ID branded types (strings not numbers) - Fix WidgetValueChangeEvent generics throughout - Fix vi.fn() mock typing for argument counts - Fix EventListener cast through unknown - Fix NodeBeforeSerializeEvent.replace callable issue - Fix VirtualNode.isVirtualNode prototype assignment - Fix NodeExecutedEvent.output property access casts - Update handler types in mock interfaces Remaining 14 items are unused variable warnings (TS6133/TS6196), not blocking compilation. Co-Authored-By: Claude Opus 4.5 --- .../__tests__/bc-01.v1.test.ts | 4 +-- .../__tests__/bc-02.migration.test.ts | 2 +- .../__tests__/bc-02.v2.test.ts | 4 +-- .../__tests__/bc-03.migration.test.ts | 2 +- .../__tests__/bc-04.migration.test.ts | 22 ++++++------- .../__tests__/bc-04.v2.test.ts | 32 +++++++++---------- .../__tests__/bc-09.v2.test.ts | 16 +++++----- .../__tests__/bc-10.migration.test.ts | 14 ++++---- .../__tests__/bc-10.v1.test.ts | 10 ++++-- .../__tests__/bc-10.v2.test.ts | 10 +++--- .../__tests__/bc-11.migration.test.ts | 2 +- .../__tests__/bc-11.v1.test.ts | 2 +- .../__tests__/bc-11.v2.test.ts | 3 +- .../__tests__/bc-12.migration.test.ts | 10 +++--- .../__tests__/bc-13.migration.test.ts | 5 ++- .../__tests__/bc-13.v2.test.ts | 2 +- .../__tests__/bc-14.migration.test.ts | 2 +- .../__tests__/bc-16.migration.test.ts | 4 +-- .../__tests__/bc-16.v2.test.ts | 3 +- .../__tests__/bc-17.migration.test.ts | 4 +-- .../__tests__/bc-19.migration.test.ts | 4 +-- .../__tests__/bc-19.v1.test.ts | 2 +- .../__tests__/bc-20.v1.test.ts | 14 +++++--- .../__tests__/bc-21.v2.test.ts | 2 +- .../__tests__/bc-33.v2.test.ts | 1 + .../__tests__/bc-35.migration.test.ts | 2 +- 26 files changed, 96 insertions(+), 82 deletions(-) diff --git a/src/extension-api-v2/__tests__/bc-01.v1.test.ts b/src/extension-api-v2/__tests__/bc-01.v1.test.ts index 7bdb60efa5..c062e9da6b 100644 --- a/src/extension-api-v2/__tests__/bc-01.v1.test.ts +++ b/src/extension-api-v2/__tests__/bc-01.v1.test.ts @@ -84,8 +84,8 @@ describe('BC.01 v1 contract — node lifecycle: creation', () => { const fakeNode = { id: 3, type: 'VAEDecode' } const callOrder: string[] = [] - const extA = { nodeCreated: vi.fn(() => callOrder.push('A')) } - const extB = { nodeCreated: vi.fn(() => callOrder.push('B')) } + const extA = { nodeCreated: vi.fn((_node: unknown) => callOrder.push('A')) } + const extB = { nodeCreated: vi.fn((_node: unknown) => callOrder.push('B')) } // Simulate the app dispatching nodeCreated to all registered extensions for (const ext of [extA, extB]) { diff --git a/src/extension-api-v2/__tests__/bc-02.migration.test.ts b/src/extension-api-v2/__tests__/bc-02.migration.test.ts index 06644fe30e..dfa121cb5f 100644 --- a/src/extension-api-v2/__tests__/bc-02.migration.test.ts +++ b/src/extension-api-v2/__tests__/bc-02.migration.test.ts @@ -131,7 +131,7 @@ describe('BC.02 migration — node lifecycle: teardown', () => { const v1Ticks = vi.fn() const v2Ticks = vi.fn() - let v2Handle: ReturnType | undefined + let v2Handle: number | undefined // v1 pattern: manual tracking const v1Handle = setInterval(v1Ticks, 100) diff --git a/src/extension-api-v2/__tests__/bc-02.v2.test.ts b/src/extension-api-v2/__tests__/bc-02.v2.test.ts index 422cd77eab..1e15878e54 100644 --- a/src/extension-api-v2/__tests__/bc-02.v2.test.ts +++ b/src/extension-api-v2/__tests__/bc-02.v2.test.ts @@ -96,7 +96,7 @@ describe('BC.02 v2 contract — node lifecycle: teardown', () => { it('cleanup fires for every node when world.clear() triggers unmount of all nodes', () => { const world = createHarnessWorld() - const cleanups: (() => void)[] = [] + const _cleanups: (() => void)[] = [] // Mount 3 nodes, collect their unmount handles const handles = [ @@ -142,7 +142,7 @@ describe('BC.02 v2 contract — node lifecycle: teardown', () => { it('interval cleared in onScopeDispose does not fire after unmount', () => { vi.useFakeTimers() const intervalCallback = vi.fn() - let handle: ReturnType | undefined + let handle: number | undefined const { unmount } = mountNode(() => { handle = setInterval(intervalCallback, 100) diff --git a/src/extension-api-v2/__tests__/bc-03.migration.test.ts b/src/extension-api-v2/__tests__/bc-03.migration.test.ts index 65c366459f..6ba421751b 100644 --- a/src/extension-api-v2/__tests__/bc-03.migration.test.ts +++ b/src/extension-api-v2/__tests__/bc-03.migration.test.ts @@ -154,7 +154,7 @@ describe('BC.03 migration — node lifecycle: hydration from saved workflows', ( // Simulate fresh creation: runtime does NOT call onConfigure / loadedGraphNode. // (Only nodeCreated / onNodeCreated fire for fresh nodes.) - const _freshNodeId = createHarnessWorld().addNode({ type: 'KSampler' }) + const ___freshNodeId = createHarnessWorld().addNode({ type: 'KSampler' }) // Neither function called — fresh creation path. expect(v1ConfigureFn).not.toHaveBeenCalled() diff --git a/src/extension-api-v2/__tests__/bc-04.migration.test.ts b/src/extension-api-v2/__tests__/bc-04.migration.test.ts index 68392582b8..fc722b9492 100644 --- a/src/extension-api-v2/__tests__/bc-04.migration.test.ts +++ b/src/extension-api-v2/__tests__/bc-04.migration.test.ts @@ -12,7 +12,7 @@ // mouseDown + selected/deselected migration tests are Phase B (API not yet present). import { describe, expect, it, vi } from 'vitest' -import type { NodeSizeChangedEvent } from '@/extension-api/node' +import type { NodeSizeChangedEvent, Size } from '@/extension-api/node' import type { Unsubscribe } from '@/extension-api/events' // ── Shared mock ─────────────────────────────────────────────────────────────── @@ -22,7 +22,7 @@ interface MockNode { event: 'sizeChanged', handler: (e: NodeSizeChangedEvent) => void ): Unsubscribe - _emitSizeChanged(size: { width: number; height: number }): void + _emitSizeChanged(size: Size): void } function createMockNode(): MockNode { @@ -38,7 +38,7 @@ function createMockNode(): MockNode { if (idx !== -1) listeners.splice(idx, 1) } }, - _emitSizeChanged(size) { + _emitSizeChanged(size: Size) { const event: NodeSizeChangedEvent = { size } for (const fn of [...listeners]) fn(event) } @@ -51,22 +51,22 @@ describe('BC.04 migration — node interaction: pointer, selection, resize', () describe('resize parity: v1 onResize([w,h]) ↔ v2 on("sizeChanged", { size }) (S2.N19)', () => { it('v2 sizeChanged handler receives same dimensions that v1 onResize received', () => { const node = createMockNode() - const v2Sizes: { width: number; height: number }[] = [] + const v2Sizes: Size[] = [] node.on('sizeChanged', (e) => v2Sizes.push(e.size)) // Simulate the same resize LiteGraph called node.onResize([300, 200]) for - node._emitSizeChanged({ width: 300, height: 200 }) + node._emitSizeChanged([300, 200]) - expect(v2Sizes).toEqual([{ width: 300, height: 200 }]) + expect(v2Sizes).toEqual([[300, 200]]) }) it('multiple resize events all reach the v2 handler (parity with repeated v1 onResize calls)', () => { const node = createMockNode() const widths: number[] = [] - node.on('sizeChanged', (e) => widths.push(e.size.width)) - node._emitSizeChanged({ width: 100, height: 50 }) - node._emitSizeChanged({ width: 200, height: 80 }) - node._emitSizeChanged({ width: 300, height: 120 }) + node.on('sizeChanged', (e) => widths.push(e.size[0])) + node._emitSizeChanged([100, 50]) + node._emitSizeChanged([200, 80]) + node._emitSizeChanged([300, 120]) expect(widths).toEqual([100, 200, 300]) }) @@ -102,7 +102,7 @@ describe('BC.04 migration — node interaction: pointer, selection, resize', () const handler = vi.fn() const unsub = node.on('sizeChanged', handler) unsub() - node._emitSizeChanged({ width: 100, height: 50 }) + node._emitSizeChanged([100, 50]) expect(handler).not.toHaveBeenCalled() }) }) diff --git a/src/extension-api-v2/__tests__/bc-04.v2.test.ts b/src/extension-api-v2/__tests__/bc-04.v2.test.ts index d020b9da49..602cd31a54 100644 --- a/src/extension-api-v2/__tests__/bc-04.v2.test.ts +++ b/src/extension-api-v2/__tests__/bc-04.v2.test.ts @@ -11,7 +11,7 @@ // Harness: inline MockNodeHandle — no ECS world needed for type-shape + event tests. import { describe, expect, it, vi } from 'vitest' -import type { NodeSizeChangedEvent } from '@/extension-api/node' +import type { NodeSizeChangedEvent, Size } from '@/extension-api/node' import type { Unsubscribe } from '@/extension-api/events' // ── Minimal mock ────────────────────────────────────────────────────────────── @@ -21,7 +21,7 @@ interface SizeChangedEmitter { event: 'sizeChanged', handler: (e: NodeSizeChangedEvent) => void ): Unsubscribe - _emitSizeChanged(size: { width: number; height: number }): void + _emitSizeChanged(size: Size): void } function createMockNode(): SizeChangedEmitter { @@ -37,7 +37,7 @@ function createMockNode(): SizeChangedEmitter { if (idx !== -1) listeners.splice(idx, 1) } }, - _emitSizeChanged(size) { + _emitSizeChanged(size: Size) { const event: NodeSizeChangedEvent = { size } for (const fn of [...listeners]) fn(event) } @@ -48,26 +48,24 @@ function createMockNode(): SizeChangedEmitter { describe('BC.04 v2 contract — node interaction: pointer, selection, resize', () => { describe("on('sizeChanged') — resize feedback (S2.N19)", () => { - it('fires with { size: { width, height } } when node dimensions change', () => { + it('fires with { size: [width, height] } when node dimensions change', () => { const node = createMockNode() - const handler = vi.fn<[NodeSizeChangedEvent], void>() + const handler = vi.fn<(e: NodeSizeChangedEvent) => void>() node.on('sizeChanged', handler) - node._emitSizeChanged({ width: 300, height: 200 }) + node._emitSizeChanged([300, 200]) expect(handler).toHaveBeenCalledOnce() - expect(handler).toHaveBeenCalledWith({ - size: { width: 300, height: 200 } - }) + expect(handler).toHaveBeenCalledWith({ size: [300, 200] }) }) it('fires again on subsequent resize; each call gets the latest size', () => { const node = createMockNode() - const sizes: { width: number; height: number }[] = [] + const sizes: Size[] = [] node.on('sizeChanged', (e) => sizes.push(e.size)) - node._emitSizeChanged({ width: 100, height: 50 }) - node._emitSizeChanged({ width: 200, height: 80 }) + node._emitSizeChanged([100, 50]) + node._emitSizeChanged([200, 80]) expect(sizes).toEqual([ - { width: 100, height: 50 }, - { width: 200, height: 80 } + [100, 50], + [200, 80] ]) }) @@ -76,7 +74,7 @@ describe('BC.04 v2 contract — node interaction: pointer, selection, resize', ( const handler = vi.fn() const unsub = node.on('sizeChanged', handler) unsub() - node._emitSizeChanged({ width: 300, height: 200 }) + node._emitSizeChanged([300, 200]) expect(handler).not.toHaveBeenCalled() }) @@ -86,7 +84,7 @@ describe('BC.04 v2 contract — node interaction: pointer, selection, resize', ( b = vi.fn() node.on('sizeChanged', a) node.on('sizeChanged', b) - node._emitSizeChanged({ width: 150, height: 120 }) + node._emitSizeChanged([150, 120]) expect(a).toHaveBeenCalledOnce() expect(b).toHaveBeenCalledOnce() }) @@ -98,7 +96,7 @@ describe('BC.04 v2 contract — node interaction: pointer, selection, resize', ( const unsubA = node.on('sizeChanged', a) node.on('sizeChanged', b) unsubA() - node._emitSizeChanged({ width: 200, height: 100 }) + node._emitSizeChanged([200, 100]) expect(a).not.toHaveBeenCalled() expect(b).toHaveBeenCalledOnce() }) diff --git a/src/extension-api-v2/__tests__/bc-09.v2.test.ts b/src/extension-api-v2/__tests__/bc-09.v2.test.ts index a707935302..c1c349a27a 100644 --- a/src/extension-api-v2/__tests__/bc-09.v2.test.ts +++ b/src/extension-api-v2/__tests__/bc-09.v2.test.ts @@ -20,11 +20,11 @@ import type { NodeHandle, SlotInfo } from '@/extension-api/node' function makeSlotInfo(overrides: Partial = {}): SlotInfo { return { - entityId: 1 as SlotInfo['entityId'], + entityId: 'slot:1' as SlotInfo['entityId'], name: 'input_0', type: 'LATENT', direction: 'input', - nodeEntityId: 10 as SlotInfo['nodeEntityId'], + nodeEntityId: 'node:10' as SlotInfo['nodeEntityId'], ...overrides } } @@ -50,7 +50,7 @@ describe('BC.09 v2 contract — dynamic slot and output mutation', () => { name: 'mask', type: 'MASK', direction: 'input', - entityId: 2 as SlotInfo['entityId'] + entityId: 'slot:2' as SlotInfo['entityId'] }) ] const handle = makeNodeHandleWithSlots(slots, []) @@ -69,7 +69,7 @@ describe('BC.09 v2 contract — dynamic slot and output mutation', () => { }) it('each SlotInfo has the required fields: entityId, name, type, direction, nodeEntityId', () => { - const nodeId = 42 as SlotInfo['nodeEntityId'] + const nodeId = 'node:42' as SlotInfo['nodeEntityId'] const slot = makeSlotInfo({ name: 'latent', type: 'LATENT', @@ -91,7 +91,7 @@ describe('BC.09 v2 contract — dynamic slot and output mutation', () => { makeSlotInfo({ name: 'b', direction: 'input', - entityId: 2 as SlotInfo['entityId'] + entityId: 'slot:2' as SlotInfo['entityId'] }) ] const handle = makeNodeHandleWithSlots(slots, []) @@ -119,7 +119,7 @@ describe('BC.09 v2 contract — dynamic slot and output mutation', () => { name: 'IMAGE', type: 'IMAGE', direction: 'output', - entityId: 2 as SlotInfo['entityId'] + entityId: 'slot:2' as SlotInfo['entityId'] }) ] const handle = makeNodeHandleWithSlots([], slots) @@ -141,7 +141,7 @@ describe('BC.09 v2 contract — dynamic slot and output mutation', () => { makeSlotInfo({ name: 'out2', direction: 'output', - entityId: 2 as SlotInfo['entityId'] + entityId: 'slot:2' as SlotInfo['entityId'] }) ] const handle = makeNodeHandleWithSlots([], slots) @@ -156,7 +156,7 @@ describe('BC.09 v2 contract — dynamic slot and output mutation', () => { const outSlot = { ...shared, direction: 'output' as const, - entityId: 2 as SlotInfo['entityId'] + entityId: 'slot:2' as SlotInfo['entityId'] } const handle = makeNodeHandleWithSlots([inSlot], [outSlot]) diff --git a/src/extension-api-v2/__tests__/bc-10.migration.test.ts b/src/extension-api-v2/__tests__/bc-10.migration.test.ts index a0c755c286..7880a00b4d 100644 --- a/src/extension-api-v2/__tests__/bc-10.migration.test.ts +++ b/src/extension-api-v2/__tests__/bc-10.migration.test.ts @@ -35,13 +35,13 @@ interface MockWidgetHandle { setValue(value: unknown): void on( event: 'valueChange', - handler: (e: WidgetValueChangeEvent) => void + handler: (e: WidgetValueChangeEvent) => void ): Unsubscribe } function createDualWidget(name: string, initial: unknown = '') { const valueRef = shallowRef(initial) - const v2Listeners: Array<(e: WidgetValueChangeEvent) => void> = [] + const v2Listeners: Array<(e: WidgetValueChangeEvent) => void> = [] // v1 shape const v1: V1Widget = { name, value: initial } @@ -58,12 +58,12 @@ function createDualWidget(name: string, initial: unknown = '') { valueRef.value = newValue v1.value = newValue // Fire v2 listeners - const event: WidgetValueChangeEvent = { newValue, oldValue } + const event: WidgetValueChangeEvent = { newValue, oldValue } for (const fn of v2Listeners) fn(event) }, on( _event: 'valueChange', - handler: (e: WidgetValueChangeEvent) => void + handler: (e: WidgetValueChangeEvent) => void ): Unsubscribe { v2Listeners.push(handler) return () => { @@ -95,7 +95,7 @@ describe('BC.10 migration — widget value subscription', () => { it('v1 callback and v2 valueChange handler both fire with the new value for the same interaction', () => { const { v1, v2, simulateV1Change } = createDualWidget('steps', 20) const v1Received: unknown[] = [] - const v2Received: WidgetValueChangeEvent[] = [] + const v2Received: WidgetValueChangeEvent[] = [] v1.callback = (val) => v1Received.push(val) v2.on('valueChange', (e) => v2Received.push(e)) @@ -110,7 +110,7 @@ describe('BC.10 migration — widget value subscription', () => { it('v2 payload is { newValue, oldValue } — v1 payload is positional args; both carry the same new value', () => { const { v1, v2, simulateV1Change } = createDualWidget('cfg', 7) let v1Value: unknown - let v2Event: WidgetValueChangeEvent | undefined + let v2Event: WidgetValueChangeEvent | undefined v1.callback = (val) => { v1Value = val @@ -164,7 +164,7 @@ describe('BC.10 migration — widget value subscription', () => { it('v1 onWidgetChanged and v2 per-widget valueChange both fire for the same widget change', () => { const { v1, v2, simulateV1Change } = createDualWidget('steps', 20) const v1NodeCalls: Array<{ name: string; value: unknown }> = [] - const v2Calls: WidgetValueChangeEvent[] = [] + const v2Calls: WidgetValueChangeEvent[] = [] const node = { onWidgetChanged: (name: string, value: unknown) => diff --git a/src/extension-api-v2/__tests__/bc-10.v1.test.ts b/src/extension-api-v2/__tests__/bc-10.v1.test.ts index 20fb207c25..9321cc9484 100644 --- a/src/extension-api-v2/__tests__/bc-10.v1.test.ts +++ b/src/extension-api-v2/__tests__/bc-10.v1.test.ts @@ -135,7 +135,7 @@ describe('BC.10 v1 contract — widget value subscription', () => { }) it('onWidgetChanged fires for any widget on the node, not only those with an explicit callback', () => { - const widgetA = createV1Widget('steps', 20) + const __widgetA = createV1Widget('steps', 20) const widgetB = createV1Widget('cfg', 7) const handler = vi.fn() const node = { onWidgetChanged: handler } @@ -157,8 +157,12 @@ describe('BC.10 v1 contract — widget value subscription', () => { ] const calls: Array<[string, unknown]> = [] const node = { - onWidgetChanged: (name: string, value: unknown) => - calls.push([name, value]) + onWidgetChanged: ( + name: string, + value: unknown, + _oldValue?: unknown, + _widget?: unknown + ) => calls.push([name, value]) } // Simulate changes to all three widgets diff --git a/src/extension-api-v2/__tests__/bc-10.v2.test.ts b/src/extension-api-v2/__tests__/bc-10.v2.test.ts index 799b25f73d..5ee3c2ef26 100644 --- a/src/extension-api-v2/__tests__/bc-10.v2.test.ts +++ b/src/extension-api-v2/__tests__/bc-10.v2.test.ts @@ -27,7 +27,7 @@ interface MockWidgetHandle { setValue(value: unknown): void on( event: 'valueChange', - handler: (e: WidgetValueChangeEvent) => void + handler: (e: WidgetValueChangeEvent) => void ): Unsubscribe } @@ -36,7 +36,7 @@ function createMockWidgetHandle( initial: unknown = '' ): MockWidgetHandle { const valueRef = shallowRef(initial) - const listeners: Array<(e: WidgetValueChangeEvent) => void> = [] + const listeners: Array<(e: WidgetValueChangeEvent) => void> = [] return { name, @@ -47,12 +47,12 @@ function createMockWidgetHandle( const oldValue = valueRef.value if (newValue === oldValue) return valueRef.value = newValue - const event: WidgetValueChangeEvent = { newValue, oldValue } + const event: WidgetValueChangeEvent = { newValue, oldValue } for (const fn of listeners) fn(event) }, on( _event: 'valueChange', - handler: (e: WidgetValueChangeEvent) => void + handler: (e: WidgetValueChangeEvent) => void ): Unsubscribe { listeners.push(handler) return () => { @@ -80,7 +80,7 @@ describe('BC.10 v2 contract — widget value subscription', () => { it('handler receives the correct oldValue even after multiple sequential changes', () => { const widget = createMockWidgetHandle('seed', 0) - const received: WidgetValueChangeEvent[] = [] + const received: WidgetValueChangeEvent[] = [] widget.on('valueChange', (e) => received.push(e)) widget.setValue(1) diff --git a/src/extension-api-v2/__tests__/bc-11.migration.test.ts b/src/extension-api-v2/__tests__/bc-11.migration.test.ts index 429f9c8787..fe325bcc17 100644 --- a/src/extension-api-v2/__tests__/bc-11.migration.test.ts +++ b/src/extension-api-v2/__tests__/bc-11.migration.test.ts @@ -286,7 +286,7 @@ describe('BC.11 migration — widget imperative state writes', () => { expect(v1Node.widgets[1].name).toBe('new_widget') // v2: addWidget uses name key — 'cfg' remains at key 'cfg' regardless of insertion order - const createCmds: Record[] = [] + const _createCmds: Record[] = [] defineNode({ name: 'bc11.mig.no-drift', nodeCreated(handle) { diff --git a/src/extension-api-v2/__tests__/bc-11.v1.test.ts b/src/extension-api-v2/__tests__/bc-11.v1.test.ts index 33c91e8b2f..061da125fd 100644 --- a/src/extension-api-v2/__tests__/bc-11.v1.test.ts +++ b/src/extension-api-v2/__tests__/bc-11.v1.test.ts @@ -37,7 +37,7 @@ function createV1ComboWidget( } // Simulate LiteGraph calling widget.callback on user interaction. -function simulateUserChange(widget: V1Widget, newValue: unknown): void { +function _simulateUserChange(widget: V1Widget, newValue: unknown): void { widget.value = newValue widget.callback?.(newValue) } diff --git a/src/extension-api-v2/__tests__/bc-11.v2.test.ts b/src/extension-api-v2/__tests__/bc-11.v2.test.ts index e0a1d982b2..c4b8114350 100644 --- a/src/extension-api-v2/__tests__/bc-11.v2.test.ts +++ b/src/extension-api-v2/__tests__/bc-11.v2.test.ts @@ -5,6 +5,7 @@ // v2 replacement: WidgetHandle.setValue(v), WidgetHandle.setOption(key,v), NodeHandle.addWidget(opts) import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' +import type { WidgetHandle } from '@/extension-api/widget' // ── Mock world (same pattern as bc-01.v2.test.ts) ──────────────────────────── @@ -88,7 +89,7 @@ describe('BC.11 v2 contract — widget imperative state writes', () => { describe('WidgetHandle.setValue(v) — controlled value write (S4.W4)', () => { it('WidgetHandle.setValue(v) dispatches a SetWidgetValue command with the correct value', () => { - let widgetHandle: { setValue: (v: unknown) => void } | undefined + let widgetHandle: WidgetHandle | undefined defineNode({ name: 'bc11.v2.set-value', diff --git a/src/extension-api-v2/__tests__/bc-12.migration.test.ts b/src/extension-api-v2/__tests__/bc-12.migration.test.ts index 16e7f44281..6482f2580a 100644 --- a/src/extension-api-v2/__tests__/bc-12.migration.test.ts +++ b/src/extension-api-v2/__tests__/bc-12.migration.test.ts @@ -63,11 +63,11 @@ describe('BC.12 migration — per-widget serialization transform', () => { expectTypeOf().toEqualTypeOf() }) - it('WidgetHandle.entityId is a branded number — prevents mixing widget IDs with node IDs', () => { + it('WidgetHandle.entityId is a branded string — prevents mixing widget IDs with node IDs', () => { type EntityId = WidgetHandle['entityId'] - // Branded: assignable to number but not plain number (structurally number & { __brand }) - type IsNumber = EntityId extends number ? true : false - const branded: IsNumber = true + // Branded: assignable to string but not plain string (structurally string & { __brand }) + type IsString = EntityId extends string ? true : false + const branded: IsString = true expect(branded).toBe(true) }) @@ -102,7 +102,7 @@ describe('BC.12 migration — per-widget serialization transform', () => { describe('async transform equivalence', () => { it("v2 on('beforeSerialize') handler type accepts both sync and async functions", () => { // AsyncHandler = (e: T) => void | Promise - type Handler = Parameters[1] + type __Handler = Parameters[1] // The beforeSerialize overload's handler must accept Promise return. // We check via the on() overload signature: the second param when event='beforeSerialize' // is typed as AsyncHandler. diff --git a/src/extension-api-v2/__tests__/bc-13.migration.test.ts b/src/extension-api-v2/__tests__/bc-13.migration.test.ts index a499fa35b7..b5d06e35cd 100644 --- a/src/extension-api-v2/__tests__/bc-13.migration.test.ts +++ b/src/extension-api-v2/__tests__/bc-13.migration.test.ts @@ -80,7 +80,10 @@ function makeV2NodeManager() { await fn(event) } - return replacer ? replacer(data) : data + if (replacer !== null) { + return (replacer as (orig: Record) => Record)(data) + } + return data } } } diff --git a/src/extension-api-v2/__tests__/bc-13.v2.test.ts b/src/extension-api-v2/__tests__/bc-13.v2.test.ts index 10234544b8..6ffd80491f 100644 --- a/src/extension-api-v2/__tests__/bc-13.v2.test.ts +++ b/src/extension-api-v2/__tests__/bc-13.v2.test.ts @@ -113,7 +113,7 @@ function serializeWidgets(widgets: Array): { return { named, warnings } } -function deserializeWidgets( +function _deserializeWidgets( named: Record, specs: WidgetSpec[], warn: (msg: string) => void diff --git a/src/extension-api-v2/__tests__/bc-14.migration.test.ts b/src/extension-api-v2/__tests__/bc-14.migration.test.ts index e9a7e15744..4cdbb6301d 100644 --- a/src/extension-api-v2/__tests__/bc-14.migration.test.ts +++ b/src/extension-api-v2/__tests__/bc-14.migration.test.ts @@ -194,7 +194,7 @@ describe('BC.14 migration — graphToPrompt interception', () => { expect(typeof ext.setup).toBe('function') const result = ext.setup!() expect(result).toBeInstanceOf(Promise) - return result.then(() => { + return Promise.resolve(result).then(() => { expect(registered).toContain('setup-called') }) }) diff --git a/src/extension-api-v2/__tests__/bc-16.migration.test.ts b/src/extension-api-v2/__tests__/bc-16.migration.test.ts index 3fb0a54658..2a836bcbdf 100644 --- a/src/extension-api-v2/__tests__/bc-16.migration.test.ts +++ b/src/extension-api-v2/__tests__/bc-16.migration.test.ts @@ -67,7 +67,7 @@ describe('BC.16 migration — per-node execution output', () => { if (data.text) v1Texts.push(data.text) } v2.on('executed', (e) => { - if (e.output.text) v2Texts.push(e.output.text) + if (e.output.text) v2Texts.push(e.output.text as string[]) }) const payload = { text: ['Generated text output'], images: [] } @@ -87,7 +87,7 @@ describe('BC.16 migration — per-node execution output', () => { v1ImageCount = data.images?.length ?? 0 } v2.on('executed', (e) => { - v2ImageCount = e.output.images?.length ?? 0 + v2ImageCount = (e.output.images as unknown[] | undefined)?.length ?? 0 }) const images = [{ filename: 'a.png', subfolder: '', type: 'output' }] diff --git a/src/extension-api-v2/__tests__/bc-16.v2.test.ts b/src/extension-api-v2/__tests__/bc-16.v2.test.ts index 6ccc6857fa..d2b7522fca 100644 --- a/src/extension-api-v2/__tests__/bc-16.v2.test.ts +++ b/src/extension-api-v2/__tests__/bc-16.v2.test.ts @@ -129,7 +129,8 @@ describe('BC.16 v2 contract — NodeHandle executed event', () => { const bus = createExecutedBus() const texts: string[] = [] bus.on('executed', (e) => { - for (const t of e.output.text ?? []) texts.push(t) + for (const t of (e.output.text as string[] | undefined) ?? []) + texts.push(t) }) bus.emit( makeExecutedEvent({ output: { text: ['alpha', 'beta'], images: [] } }) diff --git a/src/extension-api-v2/__tests__/bc-17.migration.test.ts b/src/extension-api-v2/__tests__/bc-17.migration.test.ts index 5555e30ae6..785ddb6df5 100644 --- a/src/extension-api-v2/__tests__/bc-17.migration.test.ts +++ b/src/extension-api-v2/__tests__/bc-17.migration.test.ts @@ -77,7 +77,7 @@ describe('BC.17 migration — execution lifecycle events', () => { const v2Received: unknown[] = [] v1Api.addEventListener('executed', ((e: CustomEvent) => - v1Received.push(e.detail)) as EventListener) + v1Received.push(e.detail)) as unknown as EventListener) v2.on('executed', (e) => v2Received.push(e)) const payload = { nodeId: 'node:g:1', output: { text: ['hello'] } } @@ -94,7 +94,7 @@ describe('BC.17 migration — execution lifecycle events', () => { const v2Payload: unknown[] = [] v1Api.addEventListener('execution_error', ((e: CustomEvent) => - v1Detail.push(e.detail)) as EventListener) + v1Detail.push(e.detail)) as unknown as EventListener) v2.on('executionError', (e) => v2Payload.push(e)) const payload = { nodeId: 'node:g:7', message: 'CUDA OOM' } diff --git a/src/extension-api-v2/__tests__/bc-19.migration.test.ts b/src/extension-api-v2/__tests__/bc-19.migration.test.ts index 614d791ade..fc8f03b7dc 100644 --- a/src/extension-api-v2/__tests__/bc-19.migration.test.ts +++ b/src/extension-api-v2/__tests__/bc-19.migration.test.ts @@ -157,11 +157,11 @@ describe('BC.19 migration — workflow execution trigger', () => { const v2Calls: number[] = [] // v1: each assignment replaces - v1.queuePrompt = async (p) => { + v1.queuePrompt = async (_p) => { v1Calls.push(1) return } - v1.queuePrompt = async (p) => { + v1.queuePrompt = async (_p) => { v1Calls.push(2) return } diff --git a/src/extension-api-v2/__tests__/bc-19.v1.test.ts b/src/extension-api-v2/__tests__/bc-19.v1.test.ts index 2ac1b337aa..b556d24365 100644 --- a/src/extension-api-v2/__tests__/bc-19.v1.test.ts +++ b/src/extension-api-v2/__tests__/bc-19.v1.test.ts @@ -118,7 +118,7 @@ describe('BC.19 v1 contract — app.queuePrompt monkey-patch', () => { }) it('extension can inject a field into a mutable prompt object before calling orig()', async () => { - const app = createMockApp() + const _app = createMockApp() const prompts: Record[] = [] // Simulate a version of app where queuePrompt receives a prompt object diff --git a/src/extension-api-v2/__tests__/bc-20.v1.test.ts b/src/extension-api-v2/__tests__/bc-20.v1.test.ts index a2544256c9..8159babe7c 100644 --- a/src/extension-api-v2/__tests__/bc-20.v1.test.ts +++ b/src/extension-api-v2/__tests__/bc-20.v1.test.ts @@ -126,8 +126,11 @@ describe('BC.20 v1 contract — LiteGraph.registerNodeType and isVirtualNode', ( const LiteGraph = createMockLiteGraph() const app = createMockApp(LiteGraph) - class VirtualNode {} - VirtualNode.prototype.isVirtualNode = true + class VirtualNode { + static isVirtualNode = true + } + ;(VirtualNode.prototype as { isVirtualNode?: boolean }).isVirtualNode = + true app.registerExtension({ registerCustomNodes() { @@ -218,8 +221,11 @@ describe('BC.20 v1 contract — LiteGraph.registerNodeType and isVirtualNode', ( describe('S8.P1 — virtual node payload suppression (synthetic)', () => { it('serializeGraph excludes nodes with isVirtualNode === true from the output', () => { class RealNode {} - class VirtualNode {} - VirtualNode.prototype.isVirtualNode = true + class VirtualNode { + static isVirtualNode = true + } + ;(VirtualNode.prototype as { isVirtualNode?: boolean }).isVirtualNode = + true const nodes = [ { diff --git a/src/extension-api-v2/__tests__/bc-21.v2.test.ts b/src/extension-api-v2/__tests__/bc-21.v2.test.ts index 1fc9b6fce1..814e0439c5 100644 --- a/src/extension-api-v2/__tests__/bc-21.v2.test.ts +++ b/src/extension-api-v2/__tests__/bc-21.v2.test.ts @@ -23,7 +23,7 @@ import type { NodeHandle } from '@/extension-api/node' function makeWidgetHandle(overrides: Partial = {}): WidgetHandle { return { - entityId: 1 as WidgetHandle['entityId'], + entityId: 'widget:1' as WidgetHandle['entityId'], name: 'steps', widgetType: 'INT', label: 'Steps', diff --git a/src/extension-api-v2/__tests__/bc-33.v2.test.ts b/src/extension-api-v2/__tests__/bc-33.v2.test.ts index 4eaeef31c1..0c5e75ebd8 100644 --- a/src/extension-api-v2/__tests__/bc-33.v2.test.ts +++ b/src/extension-api-v2/__tests__/bc-33.v2.test.ts @@ -53,6 +53,7 @@ interface WidgetHandle { interface AppEvents { domWidgetCreated: WidgetHandle + [key: string]: unknown } function makeWidget(overrides: Partial = {}): WidgetHandle { diff --git a/src/extension-api-v2/__tests__/bc-35.migration.test.ts b/src/extension-api-v2/__tests__/bc-35.migration.test.ts index 122277a963..c2c518f3f7 100644 --- a/src/extension-api-v2/__tests__/bc-35.migration.test.ts +++ b/src/extension-api-v2/__tests__/bc-35.migration.test.ts @@ -201,7 +201,7 @@ describe('BC.35 migration — pre-queue widget validation', () => { // v1: two patches — second clobbers first's validation if not careful const v1App = makeV1App() const extAValidation = vi.fn(() => null) // ext-A passes - const extBValidation = vi.fn((): string | null => 'B rejects') + const __extBValidation = vi.fn((): string | null => 'B rejects') // v1: each patcher wraps the previous — but if ext-B directly replaces // without calling through, ext-A's validation is lost.