Skip to main content
Question

Getting parent of a node


Tomas_Havelka

Hello, Ive been trying to get parent of some SceneNode, however when I try node.parent I get runtime error “BaseNode&ChildrenMixin” is not assignable to parameter of type “SceneNode”.

I understand that I have to check whether the node supports .parent argument, but when I tried to make a typeguard for this, it just doesnt work. The idea is that this should give me only parents of instance&frame nodes.

function supportsParent(node:SceneNode): node is FrameNode | InstanceNode {
    return node.type === "FRAME" || node.type === "INSTANCE"
}

and then when im trying to do

if (supportsParent(node)){
 arr.push(node.parent)
}

I still get runtime error.

Any help appriciated

0 replies

Be the first to reply!

Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings