[TS] Use strict mode in CanvasPointer, measure, and polyfills (#617)

- Adds runtime type guard
- Adds ts-ignore that must be removed later
  * [ ] #578
This commit is contained in:
filtered
2025-02-27 00:05:40 +11:00
committed by GitHub
parent 0b59c00597
commit 3040924d76
7 changed files with 31 additions and 17 deletions

View File

@@ -1727,6 +1727,7 @@ export class LGraphNode implements Positionable, IPinnable, IColorable {
addCustomWidget<T extends IWidget>(custom_widget: T): T {
this.widgets ||= []
// @ts-ignore https://github.com/Comfy-Org/litegraph.js/issues/616
const WidgetClass = WIDGET_TYPE_MAP[custom_widget.type]
const widget = WidgetClass ? new WidgetClass(custom_widget) as IWidget : custom_widget
this.widgets.push(widget)
@@ -3188,10 +3189,13 @@ export class LGraphNode implements Positionable, IPinnable, IColorable {
if (w.disabled) ctx.globalAlpha *= 0.5
const widget_width = w.width || width
const WidgetClass = WIDGET_TYPE_MAP[w.type]
// @ts-ignore https://github.com/Comfy-Org/litegraph.js/issues/616
const WidgetClass: typeof WIDGET_TYPE_MAP[string] = WIDGET_TYPE_MAP[w.type]
if (WidgetClass) {
// @ts-ignore https://github.com/Comfy-Org/litegraph.js/issues/616
toClass(WidgetClass, w).drawWidget(ctx, { y, width: widget_width, show_text, margin })
} else {
// @ts-ignore https://github.com/Comfy-Org/litegraph.js/issues/616
w.draw?.(ctx, this, widget_width, y, H)
}
ctx.globalAlpha = editorAlpha