Skip to content

Commit f185a98

Browse files
AustinMrozDrJKL
authored andcommitted
Remove single ts-expect-error
litegraphService had a very large amount of duplicated code that was private methods. Private methods are awful and prevent reuse. These methods have all been moved to anonymous functions with no duplication. The primary purpose of this is to expose a single addNodeInput function for use in dynamic widget code. The battle to end duck violence is long and hard fought.
1 parent b5f3df0 commit f185a98

File tree

2 files changed

+162
-352
lines changed

2 files changed

+162
-352
lines changed

src/core/graph/widgets/dynamicWidgets.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import type { LGraphNode } from '@/lib/litegraph/src/LGraphNode'
22
import { transformInputSpecV1ToV2 } from '@/schemas/nodeDef/migration'
3-
43
import type { ComboInputSpec, InputSpec } from '@/schemas/nodeDefSchema'
54
import { zDynamicComboInputSpec } from '@/schemas/nodeDefSchema'
5+
import { useLitegraphService } from '@/services/litegraphService'
66
import { app } from '@/scripts/app'
77
import type { ComfyApp } from '@/scripts/app'
88

@@ -13,6 +13,7 @@ function COMFY_DYNAMICCOMBO_V3(
1313
appArg: ComfyApp,
1414
widgetName?: string
1515
) {
16+
const { addNodeInput } = useLitegraphService()
1617
const parseResult = zDynamicComboInputSpec.safeParse(untypedInputData)
1718
if (!parseResult.success) throw new Error('invalid DynamicCombo spec')
1819
const inputData = parseResult.data
@@ -60,8 +61,8 @@ function COMFY_DYNAMICCOMBO_V3(
6061
]
6162
for (const [inputType, isOptional] of inputTypes)
6263
for (const name in inputType ?? {}) {
63-
//@ts-expect-error temporary duck violence
64-
node._addInput(
64+
addNodeInput(
65+
node,
6566
transformInputSpecV1ToV2(inputType![name], {
6667
name,
6768
isOptional

0 commit comments

Comments
 (0)