Comfy-Org / Comfy-Org/ComfyUI_frontend

Improve SimplifiedWidget typing for combo widget values (thread ComboWidgetValues through options)

Open
#9,874 0 comments 0 reactions 1 assignee Claimed by @christian-byrne View on GitHub
area:vue-migration
Dominant language
TypeScript
Stars
2k
Forks
702
Avg merge
1d 8h
Merged PRs (30d)
512

Description

## Summary

Currently, `SimplifiedWidget` (in `src/types/simplifiedWidget.ts`) defaults its options generic `O` to `Record`, which means the `values` property accessed in `WidgetSelectDefault.vue` is effectively untyped at the component level.

The litegraph layer already has the correct union type defined:

```typescript
// src/lib/litegraph/src/types/widgets.ts
type ComboWidgetValues =
| string[]
| Record
| ((widget?: IComboWidget, node?: LGraphNode) => string[])
```

However, this type information is lost during the simplification step, forcing `resolveValues()` in `WidgetSelectDefault.vue` to use `unknown` and runtime `typeof` checks instead of benefiting from TypeScript's type narrowing.

## Goal

Thread `ComboWidgetValues` (or an equivalent union type) through `SimplifiedWidget` options — either via a combo-specific specialization or by constraining the options generic — so that `WidgetSelectDefault.vue` gets type-safe access to `values` without needing `unknown` + runtime `typeof` checks.

## Jumping-off Points

- `src/types/simplifiedWidget.ts` — `SimplifiedWidget` generic, `O` defaults to `Record`
- `src/lib/litegraph/src/types/widgets.ts` — `ComboWidgetValues` and `IComboWidget` already have the right types
- `src/renderer/extensions/vueNodes/widgets/components/WidgetSelectDefault.vue` — consumer that needs the type (currently uses runtime checks)

## Context

Identified during review of #8775 (Add support for values factory function in widget select combo) by @christian-byrne.

PR: https://github.com/Comfy-Org/ComfyUI_frontend/pull/8775

┆Issue is synchronized with this [Notion page](https://www.notion.so/Issue-9874-Improve-SimplifiedWidget-typing-for-combo-widget-values-thread-ComboWidgetValues-thro-3226d73d36508105958cee79324ffb77) by [Unito](https://www.unito.io)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.