Road to No Explicit Any Part 3: Litegraph (#7935)

## Summary

- Replace `any` types with proper TypeScript types in litegraph core
files
- Focused on `LGraphCanvas.ts`, `LGraphNode.ts`, and `LGraph.ts`

## Changes

**LGraphCanvas.ts:**
- `ICreatePanelOptions` interface: `closable`, `window`, `width`,
`height`
- `options` property: `skip_events`, `viewport`, `skip_render`,
`autoresize`
- `prompt` function: `value` and `callback` parameters
- `onSearchBox` return type: `string[] | void`
- `onSearchBoxSelection` callback: `name: string`, `event: MouseEvent`
- `onDrawBackground` / `onDrawForeground` callbacks: `visible_area:
Rectangle`
- Properties Panel callback parameters

**LGraphNode.ts:**
- `onDropFile` / `onDropData`: `file: File`, `filename: string`
- `action_call` option: `string` (5 occurrences)
- `onSerialize` return type: `void`
- `onDrawTitleBar.fgcolor`: `string`

**LGraph.ts:**
- `LGraphConfig`: `align_to_grid`, `links_ontop` as `boolean`
- `triggerInput`: `value: unknown`
- `setCallback`: `func: (() => void) | undefined`

┆Issue is synchronized with this [Notion
page](https://www.notion.so/PR-7935-Road-to-No-Explicit-Any-Part-3-Litegraph-2e36d73d3650819eb9f9ec9c16ebc3b9)
by [Unito](https://www.unito.io)
This commit is contained in:
Johnpaul Chiwetelu
2026-01-12 20:30:33 +01:00
committed by GitHub
parent 05f1dfe921
commit 965ab674d5
4 changed files with 52 additions and 37 deletions

View File

@@ -579,11 +579,11 @@ export class LGraphNode
onInputAdded?(this: LGraphNode, input: INodeInputSlot): void
onOutputAdded?(this: LGraphNode, output: INodeOutputSlot): void
onConfigure?(this: LGraphNode, serialisedNode: ISerialisedNode): void
onSerialize?(this: LGraphNode, serialised: ISerialisedNode): any
onSerialize?(this: LGraphNode, serialised: ISerialisedNode): void
onExecute?(
this: LGraphNode,
param?: unknown,
options?: { action_call?: any }
options?: { action_call?: string }
): void
onAction?(
this: LGraphNode,
@@ -655,10 +655,10 @@ export class LGraphNode
onDropData?(
this: LGraphNode,
data: string | ArrayBuffer,
filename: any,
file: any
filename: string,
file: File
): void
onDropFile?(this: LGraphNode, file: any): void
onDropFile?(this: LGraphNode, file: File): void
onInputClick?(this: LGraphNode, index: number, e: CanvasPointerEvent): void
onInputDblClick?(this: LGraphNode, index: number, e: CanvasPointerEvent): void
onOutputClick?(this: LGraphNode, index: number, e: CanvasPointerEvent): void
@@ -730,7 +730,7 @@ export class LGraphNode
title_height: number,
size: Size,
scale: number,
fgcolor: any
fgcolor: string
): void
onRemoved?(this: LGraphNode): void
onMouseMove?(
@@ -1301,7 +1301,7 @@ export class LGraphNode
return trigS
}
onAfterExecuteNode(param: unknown, options?: { action_call?: any }) {
onAfterExecuteNode(param: unknown, options?: { action_call?: string }) {
const trigS = this.findOutputSlot('onExecuted')
if (trigS != -1) {
this.triggerSlot(trigS, param, null, options)
@@ -1339,7 +1339,7 @@ export class LGraphNode
/**
* Triggers the node code execution, place a boolean/counter to mark the node as being executed
*/
doExecute(param?: unknown, options?: { action_call?: any }): void {
doExecute(param?: unknown, options?: { action_call?: string }): void {
options = options || {}
if (this.onExecute) {
// enable this to give the event an ID
@@ -1405,7 +1405,7 @@ export class LGraphNode
trigger(
action: string,
param: unknown,
options: { action_call?: any }
options: { action_call?: string }
): void {
const { outputs } = this
if (!outputs || !outputs.length) {
@@ -1435,7 +1435,7 @@ export class LGraphNode
slot: number,
param: unknown,
link_id: number | null,
options?: { action_call?: any }
options?: { action_call?: string }
): void {
options = options || {}
if (!this.outputs) return