add type inference for data property

This commit is contained in:
ShaMan123
2021-01-01 11:21:55 +02:00
committed by GitHub
parent 4cb558403c
commit 6ed505f70d
+14 -14
View File
@@ -34,12 +34,12 @@ export interface Box extends XYPosition {
export type SnapGrid = [number, number]; export type SnapGrid = [number, number];
export interface Node { export interface Node<T = any> {
id: ElementId; id: ElementId;
position: XYPosition; position: XYPosition;
type?: string; type?: string;
__rf?: any; __rf?: any;
data?: any; data?: T;
style?: CSSProperties; style?: CSSProperties;
className?: string; className?: string;
targetPosition?: Position; targetPosition?: Position;
@@ -55,7 +55,7 @@ export enum ArrowHeadType {
ArrowClosed = 'arrowclosed', ArrowClosed = 'arrowclosed',
} }
export interface Edge { export interface Edge<T = any> {
id: ElementId; id: ElementId;
type?: string; type?: string;
source: ElementId; source: ElementId;
@@ -72,7 +72,7 @@ export interface Edge {
animated?: boolean; animated?: boolean;
arrowHeadType?: ArrowHeadType; arrowHeadType?: ArrowHeadType;
isHidden?: boolean; isHidden?: boolean;
data?: any; data?: T;
className?: string; className?: string;
} }
@@ -93,11 +93,11 @@ export interface SelectionRect extends Rect {
draw: boolean; draw: boolean;
} }
export interface WrapEdgeProps { export interface WrapEdgeProps<T = any> {
id: ElementId; id: ElementId;
className?: string; className?: string;
type: string; type: string;
data?: any; data?: T;
onClick?: (event: React.MouseEvent, edge: Edge) => void; onClick?: (event: React.MouseEvent, edge: Edge) => void;
selected: boolean; selected: boolean;
animated?: boolean; animated?: boolean;
@@ -126,7 +126,7 @@ export interface WrapEdgeProps {
onConnectEdge: OnConnectFunc; onConnectEdge: OnConnectFunc;
} }
export interface EdgeProps { export interface EdgeProps<T = any> {
id: ElementId; id: ElementId;
source: ElementId; source: ElementId;
target: ElementId; target: ElementId;
@@ -147,7 +147,7 @@ export interface EdgeProps {
style?: CSSProperties; style?: CSSProperties;
arrowHeadType?: ArrowHeadType; arrowHeadType?: ArrowHeadType;
markerEndId?: string; markerEndId?: string;
data?: any; data?: T;
} }
export interface EdgeSmoothStepProps extends EdgeProps { export interface EdgeSmoothStepProps extends EdgeProps {
borderRadius?: number; borderRadius?: number;
@@ -164,10 +164,10 @@ export interface EdgeTextProps {
labelBgBorderRadius?: number; labelBgBorderRadius?: number;
} }
export interface NodeProps { export interface NodeProps<T = any> {
id: ElementId; id: ElementId;
type: string; type: string;
data: any; data: T;
selected: boolean; selected: boolean;
isConnectable: boolean; isConnectable: boolean;
xPos?: number; xPos?: number;
@@ -177,10 +177,10 @@ export interface NodeProps {
isDragging?: boolean; isDragging?: boolean;
} }
export interface NodeComponentProps { export interface NodeComponentProps<T = any> {
id: ElementId; id: ElementId;
type: string; type: string;
data: any; data: T;
selected?: boolean; selected?: boolean;
isConnectable: boolean; isConnectable: boolean;
transform?: Transform; transform?: Transform;
@@ -199,10 +199,10 @@ export interface NodeComponentProps {
isDragging?: boolean; isDragging?: boolean;
} }
export interface WrapNodeProps { export interface WrapNodeProps<T = any> {
id: ElementId; id: ElementId;
type: string; type: string;
data: any; data: T;
selected: boolean; selected: boolean;
scale: number; scale: number;
xPos: number; xPos: number;