[refactor] Type createNode options parameter (#9262)

## Summary
Narrow `CreateNodeOptions` from `Partial<Omit<LGraphNode, ...>>`
(exposing hundreds of properties/methods) to an explicit interface
listing only creation-time properties.

## Changes
- Replace `Partial<Omit<LGraphNode, 'constructor' | 'inputs' |
'outputs'>>` with explicit `CreateNodeOptions` interface containing
only: `pos`, `size`, `properties`, `flags`, `mode`, `color`, `bgcolor`,
`boxcolor`, `title`, `shape`, `inputs`, `outputs`
- Rename local `CreateNodeOptions` in `createModelNodeFromAsset.ts` to
`ModelNodeCreateOptions` to avoid collision

## Ecosystem verification
GitHub code search across ~50 repos confirms only `pos` and `outputs`
are used externally. All covered by the narrowed interface.

Fixes #9276
Fixes #4740
This commit is contained in:
Johnpaul Chiwetelu
2026-03-04 23:01:18 +01:00
committed by GitHub
parent 9e2299ca65
commit 82750d629d
6 changed files with 37 additions and 12 deletions

View File

@@ -22,6 +22,7 @@ import {
createBounds
} from '@/lib/litegraph/src/litegraph'
import type {
CreateNodeOptions,
GraphAddOptions,
IContextMenuValue,
Point,
@@ -885,7 +886,7 @@ export const useLitegraphService = () => {
function addNodeOnGraph(
nodeDef: ComfyNodeDefV1 | ComfyNodeDefV2,
options: Record<string, unknown> & { pos?: Point } = {},
options: CreateNodeOptions = {},
addOptions?: GraphAddOptions
): LGraphNode | null {
options.pos ??= getCanvasCenter()