From 963e4b0904e055b30ef82a7eea30569c3a10f9ca Mon Sep 17 00:00:00 2001 From: Chenlei Hu Date: Wed, 26 Feb 2025 15:03:31 -0500 Subject: [PATCH] [Type] Mark name as required prop for IBaseWidget (#623) --- src/NodeSlot.ts | 2 +- src/types/widgets.ts | 3 ++- src/widgets/BaseWidget.ts | 3 ++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/NodeSlot.ts b/src/NodeSlot.ts index ccf917546..8ce787e22 100644 --- a/src/NodeSlot.ts +++ b/src/NodeSlot.ts @@ -39,7 +39,7 @@ export function serializeSlot(slot: INodeInputSlot | INodeOutputSlot): ISerialis _layoutElement: undefined, _data: undefined, pos: isWidgetInputSlot(slot) ? undefined : slot.pos, - widget: isWidgetInputSlot(slot) && slot.widget?.name ? { name: slot.widget.name } : undefined, + widget: isWidgetInputSlot(slot) ? { name: slot.widget.name } : undefined, }, value => value === undefined) as ISerialisedNodeInputSlot | ISerialisedNodeOutputSlot } diff --git a/src/types/widgets.ts b/src/types/widgets.ts index 49d83be1b..ae09f76ff 100644 --- a/src/types/widgets.ts +++ b/src/types/widgets.ts @@ -123,9 +123,10 @@ export type TWidgetValue = IWidget["value"] export interface IBaseWidget { linkedWidgets?: IWidget[] + name: string options: IWidgetOptions + label?: string - name?: string /** Widget type (see {@link TWidgetType}) */ type?: TWidgetType value?: TWidgetValue diff --git a/src/widgets/BaseWidget.ts b/src/widgets/BaseWidget.ts index 6ccea13db..c890231f5 100644 --- a/src/widgets/BaseWidget.ts +++ b/src/widgets/BaseWidget.ts @@ -7,9 +7,9 @@ import { LiteGraph } from "@/litegraph" export abstract class BaseWidget implements IBaseWidget { linkedWidgets?: IWidget[] + name: string options: IWidgetOptions label?: string - name?: string type?: TWidgetType value?: TWidgetValue y?: number @@ -40,6 +40,7 @@ export abstract class BaseWidget implements IBaseWidget { constructor(widget: IBaseWidget) { Object.assign(this, widget) + this.name = widget.name this.options = widget.options }