I'm trying to follow along with the plugin setup guide found here and I have a very, very simple plugin that looks like this:
figma.showUI(__html__);
// @ts-ignore
console.log(figma.currentPage.selection[0].cornerRadius);
Exactly as written, the plugin works fine and returns the border radius of the selected node.
However, if I remove // @ts-ignore
TS complains: "Property 'cornerRadius' does not exist on type 'SceneNode'."
I have installed the typings, from here and my .tsconfig looks like this:
{
"compilerOptions": {
"target": "es6",
"lib": ["es6", "dom"],
"typeRoots": [
"./node_modules/@types",
"./node_modules/@figma"
]
}
}
What am I missing?
figma.currentPage.selection
returns aSceneNode
array.SceneNode
doesn't have theCornerMixin
which definescornerRadius
. You'll need to check that the node type is supported.i.e. look at the
type
field onSceneNode
:The following types use
CornerMixin
, based on the typings plugin declaration file: