mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-22 07:44:11 +00:00
fix: improve type safety in litegraph library layer - No Explicit Any mission (PR 2) (#7401)
## Summary Part 2 of the type safety remediation plan. This PR focuses on the Litegraph Library Layer as part of the **No Explicit Any** mission. ### Changes **LiteGraphGlobal.ts:** - `DEFAULT_GROUP_FONT_SIZE`: Changed from `any` (with no value) to `number = 24`. The internal fallback was already 24, so the constant was effectively useless without an assigned value. - `getParameterNames`: Replace `any` with `unknown` in function signature - `extendClass`: Replace deprecated `__lookupGetter__`/`__defineGetter__` with modern `Object.getOwnPropertyDescriptor`/`defineProperty` and add proper Record types **LGraphNodeProperties.ts:** - Replace `any` with `unknown` for property values - Use `Record<string, unknown>` with proper type assertions for dynamic property access **types/widgets.ts & BaseWidget.ts:** - Change `callback` value parameter from `any` to properly typed (`unknown` in interface, `TWidget['value']` in implementation) **Consuming code fixes:** - `previewAny.ts`: Add explicit `boolean` type annotation for callback value - `ButtonWidget.ts`: Pass widget value instead of widget instance to callback (matching the interface signature) ## Breaking Change Analysis (Sourcegraph Verified) ### ButtonWidget callback fix (`this` → `this.value`) This PR fixes the ButtonWidget callback to pass `value` instead of `this`, matching the interface definition. **Verification via Sourcegraph** - all external usages are safe: - [comfyui-ollama](https://cs.comfy.org/github.com/stavsap/comfyui-ollama/-/blob/web/js/OllamaNode.js?L84) - doesn't use callback args - [ComfyLab-Pack](https://cs.comfy.org/github.com/bugltd/ComfyLab-Pack/-/blob/dist/js/nodes/list.js?L8) - doesn't use callback args - [ComfyUI_PaintingCoderUtils](https://cs.comfy.org/github.com/jammyfu/ComfyUI_PaintingCoderUtils/-/blob/web/js/click_popup.js?L18) - doesn't use callback args - [ComfyUI-ShaderNoiseKSampler](https://cs.comfy.org/github.com/AEmotionStudio/ComfyUI-ShaderNoiseKSampler/-/blob/web/matrix_button.js?L3055-3056) - was already working around this bug --------- Co-authored-by: GitHub Action <action@github.com>
This commit is contained in:
committed by
GitHub
parent
886fe07de9
commit
a6ca2bcd42
@@ -41,7 +41,7 @@ useExtensionService().registerExtension({
|
||||
app
|
||||
)
|
||||
|
||||
showAsPlaintextWidget.widget.callback = (value) => {
|
||||
showAsPlaintextWidget.widget.callback = (value: boolean) => {
|
||||
showValueWidget.hidden = !value
|
||||
showValueWidget.options.hidden = !value
|
||||
showValueWidgetPlain.hidden = value
|
||||
|
||||
Reference in New Issue
Block a user