Skip to main content

Hey!


First of all, good job on the new API improvements. I am building something with variables and upon using figma.variables.createVariableAlias, I found inconsistent behavior between the editor interface and this method.


Specifically, I am trying to assign variables to the InstanceNode (here, “Mode” prop key):


propertiest"Mode"] = figma.variables.createVariableAlias(variable)


This works, for string properties. For numeric properties, however, an error is thrown stating that the property that I am trying to assign can’t resolve to “string”. Now I assume this is because the API requires only string properties to be assigned (Working with Variables | Plugin API) - just an assumption - however this limitation doesn’t exist when using the editor:


CleanShot 2023-06-23 at 14.57.23


In editor, numeric variable can be bound just fine. This is quite a big limitation, because any real conditionals will usually work with numbers.


Possibly I am missing something, but this seems like a bug in the SDK layer to me.


Thank you!

Thanks for reporting this! This is an API bug that we plan to fix.


@James_Yang any updates on this?


After looking into this, this is currently an expected limitation of the plugin API.


The UI does some additional work (using a string-ification expression) to make numeric variables work in these kinds of bindings. To support the same behavior in the plugin API, we need to make these number → string conversions explicit and implement an expressions system. This is something we plan to do, but with the amount of work involved, unfortunately it’s not coming anytime soon.


Reply