[TS] Use strict mode in LGraphCanvas (#673)

- Adds remaining TS nullable types
- Adds type guards to allow strict mode
  - Uses explicit throw in places that would throw regardless
- Adds ts-ignore that must be removed later
  * [ ] #578
This commit is contained in:
filtered
2025-03-03 00:34:02 +11:00
committed by GitHub
parent 41e552b719
commit 6cb9131035
4 changed files with 58 additions and 48 deletions

View File

@@ -472,8 +472,8 @@ export class LGraphNode implements Positionable, IPinnable, IColorable {
getExtraMenuOptions?(
this: LGraphNode,
canvas: LGraphCanvas,
options: IContextMenuValue[],
): IContextMenuValue[]
options: (IContextMenuValue<unknown> | null)[],
): (IContextMenuValue<unknown> | null)[]
getMenuOptions?(this: LGraphNode, canvas: LGraphCanvas): IContextMenuValue[]
onAdded?(this: LGraphNode, graph: LGraph): void
onDrawCollapsed?(
@@ -3152,7 +3152,7 @@ export class LGraphNode implements Positionable, IPinnable, IColorable {
drawWidgets(ctx: CanvasRenderingContext2D, options: {
colorContext: ConnectionColorContext
linkOverWidget: IWidget
linkOverWidget: IWidget | null | undefined
linkOverWidgetType: ISlotType
lowQuality?: boolean
editorAlpha?: number
@@ -3316,7 +3316,7 @@ export class LGraphNode implements Positionable, IPinnable, IColorable {
* Draws the node's input and output slots.
*/
drawSlots(ctx: CanvasRenderingContext2D, options: {
connectingLink: ConnectingLink | null
connectingLink: ConnectingLink | undefined
colorContext: ConnectionColorContext
editorAlpha: number
lowQuality: boolean