Custom Node Documentation incorrect? #1772
-
Hello! Wasn't sure whether to raise this as a an issue or not, as I may be at fault! Currently looking at implementing some custom Nodes - based off behaviour trees. I'm following along with the documentation, using TypeScript, here: Firstly, it looks like './nodes' file is missing, referenced in I have assumed this is a typo, and should be imported from the
Having "corrected" that, and error when defining the CustomNode type: Previously I had tried converting the CustomEvents to a type, but that kicked errors down to the component instead. Is there any examples setting up Custom Nodes with TypeScript? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
True, I'll inline the types so it's clear what they represent. As to the rest of your issues:
interface ColorSelectorData {
color: string
}
type ColorSelectorNode = Node<ColorSelectorData, {}, 'color-selector'>
import type { Node } from '@vue-flow/core'
interface ColorSelectorData {
color: string
}
interface CustomEvents extends Record<string, any> {
onColorChange: (color: string) => void
}
type ColorSelectorNode = Node<ColorSelectorData, CustomEvents, 'color-selector'> Or just inline the events into |
Beta Was this translation helpful? Give feedback.
True, I'll inline the types so it's clear what they represent.
As to the rest of your issues:
node.data
.Node
type could look like this:CustomEvents
you can try this: