antvis/G6
Do you want to work on this issue?
You can request for a bounty in order to promote it!
[Bug]: type Element used in events is missing methods #6827
Crystal-RainSlide posted onGitHub
Describe the bug / é®é¢ęčæ°
For example, methods in BaseNode
like: drawKeyShape()
, getIconStyle()āā
, and getKeyStyle()
don't exist on interface Node
.
In this branch, I added:
type TargetElement = BaseNode | BaseEdge | BaseCombo;
Then I replaced references to Element
with TargetElement
.
https://github.com/Crystal-RainSlide/G6/tree/refactor-TargetElement
I can start a PR if you accept this solution. I'ill add the missing references if you find any.
Reproduction link / å¤ē°é¾ę„
No response
Steps to Reproduce the Bug or Issue / éē°ę„éŖ¤
new G6.Graph({
// other options...
behaviors: [
/** @type {import("@antv/g6").ClickSelectOptions} */
({
type: "click-select",
onClick: ({ target }) => {
if ("getPorts" in target) { // Narrow target down from (Document | Element) to (Node | Combo)
// TypeScript Error: target (Node | Combo) has no "drawKeyShape" method
console.log(target.drawKeyShape);
// Actually can log the method without type error
}
},
}),
],
});
Version / ēę¬
š 5.x
OS / ęä½ē³»ē»
- macOS
- Windows
- Linux
- Others / å ¶ä»
Browser / ęµč§åØ
- Chrome
- Edge
- Firefox
- Safari (Limited support / ęéęÆę)
- IE (Nonsupport / äøęÆę)
- Others / å ¶ä»