refactor: remove any types from contextMenuCompat.test.ts

- Replace ...args: any[] with proper return type annotations
- Replace (original as any).apply() with original.call()
- Replace (originalGetCanvasMenuOptions as any).apply() with .call()
- Add explicit return type (IContextMenuValue | null)[] to functions
This commit is contained in:
Johnpaul
2026-01-21 21:48:30 +01:00
parent 489af6df76
commit acccd6c3a7

View File

@@ -54,11 +54,12 @@ describe('contextMenuCompat', () => {
// Simulate extension monkey-patching
const original = LGraphCanvas.prototype.getCanvasMenuOptions
LGraphCanvas.prototype.getCanvasMenuOptions = function (...args: any[]) {
const items = (original as any).apply(this, args)
items.push({ content: 'Custom Item', callback: () => {} })
return items
}
LGraphCanvas.prototype.getCanvasMenuOptions =
function (): (IContextMenuValue | null)[] {
const items = original.call(this)
items.push({ content: 'Custom Item', callback: () => {} })
return items
}
// Should have logged a warning with extension name
expect(warnSpy).toHaveBeenCalledWith(
@@ -83,8 +84,10 @@ describe('contextMenuCompat', () => {
legacyMenuCompat.install(LGraphCanvas.prototype, methodName)
legacyMenuCompat.setCurrentExtension('test.extension')
const patchFunction = function (this: LGraphCanvas, ...args: any[]) {
const items = (originalGetCanvasMenuOptions as any).apply(this, args)
const patchFunction = function (
this: LGraphCanvas
): (IContextMenuValue | null)[] {
const items = originalGetCanvasMenuOptions.call(this)
items.push({ content: 'Custom', callback: () => {} })
return items
}