Skip to content
Merged
9 changes: 7 additions & 2 deletions src/lib/litegraph/src/LGraph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -842,8 +842,13 @@ export class LGraph
if (!list_of_graphcanvas) return

for (const c of list_of_graphcanvas) {
// eslint-disable-next-line prefer-spread
c[action]?.apply(c, params)
const method = c[action]

if (typeof method === 'function') {
const args =
params == null ? [] : Array.isArray(params) ? params : [params]
;(method as (...args: unknown[]) => unknown).apply(c, args)
}
Comment on lines +845 to +851
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const method = c[action]
if (typeof method === 'function') {
const args =
params == null ? [] : Array.isArray(params) ? params : [params]
;(method as (...args: unknown[]) => unknown).apply(c, args)
}
this.canvasAction((c) => c[action]?.(params))

From personal testing, the above seems to satisfy the compiler.

I would hope that there's a nicer way to do this given how well typed the inputs to this function are, but it's not anything I would consider blocking.

}
}

Expand Down
Loading