You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Loving your plugin, kudos for releasing it as FOSS! It's such a time saver to have a basic bundler and UI framework integration from the get go!
I'd like to suggest adding type guard functions for common node operations as part of the template, e.g. hasChildren or isComponentNode, to helps folks less familiar with TypeScript not get stuck on a common issue with handling Figma Plugin API data.
// src-code/utils/type-guards.tsexportfunctionisComponentNode(node: BaseNode): node is ComponentNode{returnnode.type==='COMPONENT';}// src-code/code.tslistenTS("processComponent",async(res)=>{constnode=awaitfigma.getNodeByIdAsync(res.nodeId);if(!isComponentNode(node)){thrownewError(`Node ${nodeId} is of type '${node.type}', expected 'COMPONENT'.`)}// Do things that require a component node here...dispatchTS("processComponentCallback",{result: true});});
I think this is something that could easily grow over time, and would also be easy to adjust and extend, but folks not familiar with type guards would likely greatly benefit from an example.
Thanks!
The text was updated successfully, but these errors were encountered:
Hi folks,
Loving your plugin, kudos for releasing it as FOSS! It's such a time saver to have a basic bundler and UI framework integration from the get go!
I'd like to suggest adding type guard functions for common node operations as part of the template, e.g.
hasChildren
orisComponentNode
, to helps folks less familiar with TypeScript not get stuck on a common issue with handling Figma Plugin API data.I think this is something that could easily grow over time, and would also be easy to adjust and extend, but folks not familiar with type guards would likely greatly benefit from an example.
Thanks!
The text was updated successfully, but these errors were encountered: