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
This commit is contained in:
Johnpaul
2026-01-21 21:41:03 +01:00
parent 692528cd12
commit 489af6df76

View File

@@ -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
}