antvis/G6

TS: getModel and updateChild have not compatible types #3488

monolithed posted onGitHub

Describe the bug

updateChild(data: TreeGraphData, parentId?: string): void;
getModel: () => NodeConfig | EdgeConfig | ComboConfig | TreeGraphData;

Steps to Reproduce the Bug or Issue

const model = item!.getModel();

graph.updateChild(model, model.id);
TS2345: Argument of type 'NodeConfig | EdgeConfig | ComboConfig | TreeGraphData' is not assignable to parameter of type 'TreeGraphData'.   
Type 'NodeConfig' is not assignable to type 'TreeGraphData'.
Types of property 'label' are incompatible.
Type 'string | Partial<{ rotate: number; textAlign: "center" | "start" | "end" | "left" | "right"; angle: number; x: number; y: number; text: string; stroke: string | null; opacity: number; fontSize: number; ... 14 more ...; background?: { ...; } | undefined; }> | undefined' is not assignable to type 'string | undefined'.
Type 'Partial<{ rotate: number; textAlign: "center" | "start" | "end" | "left" | "right"; angle: number; x: number; y: number; text: string; stroke: string | null; opacity: number; fontSize: number; fontStyle: "normal" | ... 1 more ... | "oblique"; ... 13 more ...; background?: { ...; } | undefined; }>' is not assignable to type 'string'.

Expected behavior

No errors


Fund this Issue

$0.00
Funded

Pull requests