Skip to content
Closed
Prev Previous commit
Next Next commit
End duck violence
I would prefer that valueRef used the TValue generic, but that causes
many, many awful errors. This is far preferable
  • Loading branch information
AustinMroz committed Dec 13, 2025
commit a50eb8dd57f89d195e4686ad3570d6f1be303911
6 changes: 1 addition & 5 deletions src/composables/graph/useGraphNodeManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ export function safeWidgetMapper(
) {
widget.value = widget.options.values[0]
}
//@ts-expect-error duck violence
if (!widget.valueRef) {
const valueRef = ref(widget.value)
watch(valueRef, (newValue) => {
Expand All @@ -128,10 +127,8 @@ export function safeWidgetMapper(
})
widget.callback = useChainCallback(widget.callback, () => {
if (valueRef.value !== widget.value)
//@ts-expect-error duck violence
valueRef.value = validateWidgetValue(widget.value)
valueRef.value = validateWidgetValue(widget.value) ?? undefined
})
//@ts-expect-error duck violence
widget.valueRef = () => valueRef
}
const spec = nodeDefStore.getInputSpecForWidget(node, widget.name)
Expand All @@ -145,7 +142,6 @@ export function safeWidgetMapper(
return {
name: widget.name,
type: widget.type,
//@ts-expect-error duck violence
value: widget.valueRef,
borderStyle,
isDOMWidget: isDOMWidget(widget),
Expand Down
3 changes: 3 additions & 0 deletions src/lib/litegraph/src/types/widgets.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import type { Ref } from 'vue'

import type { CanvasColour, Point, RequiredProps, Size } from '../interfaces'
import type { CanvasPointer, LGraphCanvas, LGraphNode } from '../litegraph'
import type { CanvasPointerEvent } from './events'
Expand Down Expand Up @@ -284,6 +286,7 @@ export interface IBaseWidget<
/** Widget type (see {@link TWidgetType}) */
type: TType
value?: TValue
valueRef?: () => Ref<boolean | number | string | object | undefined>
Copy link
Contributor

Choose a reason for hiding this comment

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

Might be able to get this to work if you use NoInfer


/**
* Whether the widget value should be serialized on node serialization.
Expand Down