Comfy-Org / Comfy-Org/ComfyUI_frontend
Duplicate input spec type guards: nodeDefSchema.ts V1 vs nodeDefSchemaV2.ts
- Dominant language
- TypeScript
- Stars
- 2k
- Forks
- 704
- Avg merge
- 1d 8h
- Merged PRs (30d)
- 512
Description
## Problem
Two parallel sets of input spec type guard functions exist:
**V1** in `src/schemas/nodeDefSchema.ts`:
- `isIntInputSpec()`, `isFloatInputSpec()`, `isComboInputSpec()`
- Plus V1-specific: `isComboInputSpecV1()`, `isComboInputSpecV2()`
**V2** in `src/schemas/nodeDef/nodeDefSchemaV2.ts`:
- `isIntInputSpec()`, `isFloatInputSpec()`, `isComboInputSpec()`
- Plus: `isBooleanInputSpec()`, `isStringInputSpec()`, `isChartInputSpec()`
### Current usage
- **V2 callers** (new Vue renderer): `useFloatWidget`, `useIntWidget`, `useComboWidget`, `WidgetSelect.vue`
- **V1 callers** (legacy): `app.ts`, `uploadImage.ts`, `groupNode.ts`, `widgetInputs.ts`, `migration.ts`, `nodeDefUtil.ts`, `dynamicWidgets.ts`, `useNodePricing.ts`
20+ files still import types/functions from V1. The V1 file's Zod schemas (`ComfyNodeDef`, `InputSpec`, `PriceBadge`, etc.) are still widely used, but the duplicate type guard functions should be consolidated.
### Impact
- Confusing API: two functions named `isComboInputSpec` with different signatures
- `isComboInputSpecV1` / `isComboInputSpecV2` naming suggests a migration that stalled
- New code risks importing the wrong version
### Suggested fix
1. Keep V2 type guards as the canonical versions
2. Update V1 callers to use V2 equivalents (may need adapter for V1 input format)
3. Remove duplicate functions from `nodeDefSchema.ts`, keeping only the Zod schemas and types
### Files involved
- `src/schemas/nodeDefSchema.ts`
- `src/schemas/nodeDef/nodeDefSchemaV2.ts`
- `src/schemas/nodeDef/migration.ts`
- 20+ consumer files
Parent: #11022
┆Issue is synchronized with this [Notion page](https://www.notion.so/Issue-11101-Duplicate-input-spec-type-guards-nodeDefSchema-ts-V1-vs-nodeDefSchemaV2-ts-33e6d73d365081ccb32fc529215c02c2) by [Unito](https://www.unito.io)
Contributor guide
Research direction
Start with the duplicate guards in src/schemas/nodeDefSchema.ts and src/schemas/nodeDef/nodeDefSchemaV2.ts, then trace the listed V1 consumers and the adapter work in src/schemas/nodeDef/migration.ts. Check which callers can use the V2 equivalents and identify any V1 input-format differences. Done means the consumer imports are consolidated, duplicate guards are removed, and the V1 Zod schemas and types remain available.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- frontend
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100