[TS] Improve types and (#1043)

This commit is contained in:
filtered
2025-05-13 05:02:57 +10:00
committed by GitHub
parent 10118d95e3
commit de32560816
11 changed files with 160 additions and 52 deletions

View File

@@ -4,8 +4,7 @@
import type { LGraphGroup } from "../LGraphGroup"
import type { LGraphNode } from "../LGraphNode"
import type { ConnectingLink, LinkReleaseContextExtended } from "../litegraph"
import type { IWidget } from "./widgets"
import type { LinkReleaseContextExtended } from "../litegraph"
/** For Canvas*Event - adds graph space co-ordinates (property names are shipped) */
export interface ICanvasPosition {
@@ -57,12 +56,9 @@ export interface CanvasDragEvent extends
export type CanvasEventDetail =
| GenericEventDetail
| DragggingCanvasEventDetail
| ReadOnlyEventDetail
| GroupDoubleClickEventDetail
| NodeDoubleClickEventDetail
| EmptyDoubleClickEventDetail
| ConnectingWidgetLinkEventDetail
| EmptyReleaseEventDetail
export interface GenericEventDetail {
@@ -78,13 +74,6 @@ export interface EmptyReleaseEventDetail extends OriginalEvent {
linkReleaseContext: LinkReleaseContextExtended
}
export interface ConnectingWidgetLinkEventDetail {
subType: "connectingWidgetLink"
link: ConnectingLink
node: LGraphNode
widget: IWidget
}
export interface EmptyDoubleClickEventDetail extends OriginalEvent {
subType: "empty-double-click"
}
@@ -98,13 +87,3 @@ export interface NodeDoubleClickEventDetail extends OriginalEvent {
subType: "node-double-click"
node: LGraphNode
}
export interface DragggingCanvasEventDetail {
subType: "dragging-canvas"
draggingCanvas: boolean
}
export interface ReadOnlyEventDetail {
subType: "read-only"
readOnly: boolean
}

View File

@@ -34,7 +34,7 @@ export interface BaseExportedGraph {
/** Unique graph ID. Automatically generated if not provided. */
id: UUID
revision: number
config: LGraphConfig
config?: LGraphConfig
/** Details of the appearance and location of subgraphs shown in this graph. Similar to */
subgraphs?: ExportedSubgraphInstance[]
/** Definitions of re-usable objects that are referenced elsewhere in this exported graph. */
@@ -161,7 +161,7 @@ export interface ISerialisedGroup {
title: string
bounding: number[]
color?: string
font_size: number
font_size?: number
flags?: IGraphGroupFlags
}

13
src/types/utility.ts Normal file
View File

@@ -0,0 +1,13 @@
/**
* General-purpose, TypeScript utility types.
*/
/** {@link Pick} only properties that evaluate to `never`. */
export type PickNevers<T> = {
[K in keyof T as T[K] extends never ? K : never]: T[K]
}
/** {@link Omit} all properties that evaluate to `never`. */
export type NeverNever<T> = {
[K in keyof T as T[K] extends never ? never : K]: T[K]
}