Update Litegraph (TypeScript conversion) (#1145)

* Fix various type errors

* Fix rest of ts errors

* update litegraph

* nit
This commit is contained in:
Chenlei Hu
2024-10-07 11:31:54 -04:00
committed by GitHub
parent 9cbfc9856b
commit dee1ec1a2a
15 changed files with 36 additions and 69 deletions

View File

@@ -60,7 +60,7 @@ class PrimitiveNode extends LGraphNode {
]
let v = this.widgets?.[0].value
if (v && this.properties[replacePropertyName]) {
v = applyTextReplacements(app, v)
v = applyTextReplacements(app, v as string)
}
// For each output link copy our value over the original widget value
@@ -97,7 +97,7 @@ class PrimitiveNode extends LGraphNode {
if (widget?.type === 'combo') {
widget.options.values = this.outputs[0].widget[GET_CONFIG]()[0]
if (!widget.options.values.includes(widget.value)) {
if (!widget.options.values.includes(widget.value as string)) {
widget.value = widget.options.values[0]
;(widget.callback as Function)(widget.value)
}
@@ -115,6 +115,7 @@ class PrimitiveNode extends LGraphNode {
for (let i = 0; i < this.widgets_values.length; i++) {
const w = this.widgets[i]
if (w) {
// @ts-expect-error change widget type from string to unknown
w.value = this.widgets_values[i]
}
}
@@ -247,6 +248,7 @@ class PrimitiveNode extends LGraphNode {
)
let filter = this.widgets_values?.[2]
if (filter && this.widgets.length === 3) {
// @ts-expect-error change widget type from string to unknown
this.widgets[2].value = filter
}
}
@@ -489,9 +491,7 @@ export function convertToInput(
const sz = node.size
const inputIsOptional = !!widget.options?.inputIsOptional
const input = node.addInput(widget.name, type, {
// @ts-expect-error GET_CONFIG is not defined in LiteGraph
widget: { name: widget.name, [GET_CONFIG]: () => config },
// @ts-expect-error LiteGraph.SlotShape is not typed.
...(inputIsOptional ? { shape: LiteGraph.SlotShape.HollowCircle } : {})
})