From 489af6df7618d814ffbc301c93a644000cd6bc85 Mon Sep 17 00:00:00 2001 From: Johnpaul Date: Wed, 21 Jan 2026 21:41:03 +0100 Subject: [PATCH] refactor: remove any types from contextMenuFilter.name.test.ts - Import IContextMenuValue and LGraphNode types - Replace ...args: any[] with proper parameter types (none for getCanvasMenuOptions, node: LGraphNode for getNodeMenuOptions) - Replace (original as any).apply() with original.call() with proper typing - Add explicit return type annotation for monkey-patched methods --- .../core/contextMenuFilter.name.test.ts | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/extensions/core/contextMenuFilter.name.test.ts b/src/extensions/core/contextMenuFilter.name.test.ts index 1fb0b5fd5..2ee4f6a21 100644 --- a/src/extensions/core/contextMenuFilter.name.test.ts +++ b/src/extensions/core/contextMenuFilter.name.test.ts @@ -1,6 +1,10 @@ import { describe, expect, it, vi } from 'vitest' import { legacyMenuCompat } from '@/lib/litegraph/src/contextMenuCompat' +import type { + IContextMenuValue, + LGraphNode +} from '@/lib/litegraph/src/litegraph' import { LGraphCanvas } from '@/lib/litegraph/src/litegraph' /** @@ -18,11 +22,12 @@ describe('Context Menu Extension Name in Warnings', () => { // Extension monkey-patches the method const original = LGraphCanvas.prototype.getCanvasMenuOptions - LGraphCanvas.prototype.getCanvasMenuOptions = function (...args: any[]) { - const items = (original as any).apply(this, args) - items.push({ content: 'My Custom Menu Item', callback: () => {} }) - return items - } + LGraphCanvas.prototype.getCanvasMenuOptions = + function (): (IContextMenuValue | null)[] { + const items = original.call(this) + items.push({ content: 'My Custom Menu Item', callback: () => {} }) + return items + } // Clear extension (happens after setup completes) legacyMenuCompat.setCurrentExtension(null) @@ -49,8 +54,8 @@ describe('Context Menu Extension Name in Warnings', () => { // Extension monkey-patches the method const original = LGraphCanvas.prototype.getNodeMenuOptions - LGraphCanvas.prototype.getNodeMenuOptions = function (...args: any[]) { - const items = (original as any).apply(this, args) + LGraphCanvas.prototype.getNodeMenuOptions = function (node: LGraphNode) { + const items = original.call(this, node) items.push({ content: 'My Node Menu Item', callback: () => {} }) return items }