How to retrieve componentPropertyDefinitions from team library component instance?

I have my code running fine retrieving the componentPropertyDefinitions of local components I look up the mainComponent and find the componentSetNode and pull the property definitions there but when I try to pull it from an instance that is from a team library it fails to show it at all just empty javascript object and when I look at the parent node is not a componentSetNode but a page node?

Does anyone have any insight on this?

Could you share a code example?

let nodes=figma.currentPage.selection;`

    const ComponentSet=node.mainComponent.parent as ComponentSetNode;
    console.log(ComponentSet.componentPropertyDefinitions );

In that example, it works if the component is a local component but if its a component from a team library first the parent is not a componentNodeSet but rather a pageNode. When I run the plugin in the same file as the component that is in a team library it pulls the information with no issue.

Are you sure the instance you selected has a ComponentNodeSet parent? Maybe it’s just a ComponentNode?

Yeah I am sure its a component node I drag the component from the Team library and literally just click it and run the plugin and it shows up as the node.maincomponent.parent is a pagenode rather than a componentSetNode. But When I try the same thing creating an instance of the same component in the local file it was created in it works. I honestly think it’s a bug in Figma because this outcome is not right and I am stumped

Sorry, but I can’t confirm this.

I created a file for you that has 4 component instances (2 from the library and 2 local).

Please duplicate this file and test your plugin against it, then post your results.

1 Like

Idk what is different I did not change anything with my code but when I open your file it shows the component set and when I went back to my file it now shows as a component set and not a page node… :crazy_face: I guess solved? I have screenshots of it as a pagenode no matter what I did.

Oh well I will continue and I will return to this thread if I find the issue again with more insight thank you for your help

In my file, there are only 2 instances whose parent is ComponentSetNode. 2 more instances are instances of individual components that do not have component sets at all. That is, your code (which you provided above) should only print 2 results to the console for instances whose parent is ComponentSetNode.

By the way, I added 2 more instances to the file. And it would be great if you wrote about the results for each instance in order.

Okay here the result individually

  1. When selected produces nothing in the console.
  2. When selected nothing is shown in the console.
  3. Shows property definitions in the console
  4. Shows property definitions in the console.

1 and 2. Don’t have a ComponentSetNode. The ComponentPropertyDefinitions is at the ComponentNode level.
3 and 4. Have a ComponentSetNode.
5 and 6. Have neither ComponentSetNode nor component properties.

That is, only instances 5 and 6 should have an empty object.