mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-29 02:32:18 +00:00
[TS] Properly type slot widget (#876)
INodeSlot.widget is not real widget references at runtime. This PR narrows the type so that we don't run into unexpected issues.
This commit is contained in:
@@ -3,7 +3,6 @@ import type { LGraphNode, NodeId } from "./LGraphNode"
|
||||
import type { LinkId, LLink } from "./LLink"
|
||||
import type { Reroute, RerouteId } from "./Reroute"
|
||||
import type { LinkDirection, RenderShape } from "./types/globalEnums"
|
||||
import type { IWidget } from "./types/widgets"
|
||||
import type { LayoutElement } from "./utils/layout"
|
||||
|
||||
export type Dictionary<T> = { [key: string]: T }
|
||||
@@ -306,17 +305,25 @@ export interface INodeFlags {
|
||||
keepAllLinksOnBypass?: boolean
|
||||
}
|
||||
|
||||
/**
|
||||
* A widget that is linked to a slot.
|
||||
*
|
||||
* This is set by the ComfyUI_frontend logic. See
|
||||
* https://github.com/Comfy-Org/ComfyUI_frontend/blob/b80e0e1a3c74040f328c4e344326c969c97f67e0/src/extensions/core/widgetInputs.ts#L659
|
||||
*/
|
||||
export interface IWidgetLocator {
|
||||
name: string
|
||||
[key: string | symbol]: unknown
|
||||
}
|
||||
|
||||
export interface INodeInputSlot extends INodeSlot {
|
||||
link: LinkId | null
|
||||
_layoutElement?: LayoutElement<INodeInputSlot>
|
||||
/**
|
||||
* A widget that is linked to this input slot.
|
||||
*/
|
||||
widget?: IWidget
|
||||
widget?: IWidgetLocator
|
||||
}
|
||||
|
||||
export interface IWidgetInputSlot extends INodeInputSlot {
|
||||
widget: IWidget
|
||||
widget: IWidgetLocator
|
||||
}
|
||||
|
||||
export interface INodeOutputSlot extends INodeSlot {
|
||||
|
||||
Reference in New Issue
Block a user