我试着按照here找到的插件安装指南进行操作,我有一个非常非常简单的插件,看起来像这样:
figma.showUI(__html__);
// @ts-ignore
console.log(figma.currentPage.selection[0].cornerRadius);正如所写的那样,该插件运行良好,并返回所选节点的边界半径。
但是,如果我删除了SceneNode,TS会抱怨:“类型‘// @ts-ignore’上不存在属性'cornerRadius‘。”
我已经安装了来自here的类型,并且我的.tsconfig看起来像这样:
{
"compilerOptions": {
"target": "es6",
"lib": ["es6", "dom"],
"typeRoots": [
"./node_modules/@types",
"./node_modules/@figma"
]
}}
我遗漏了什么?
发布于 2021-09-13 20:57:41
figma.currentPage.selection returns a SceneNode array.SceneNode没有定义cornerRadius的CornerMixin。您需要检查节点类型是否受支持。
例如,查看SceneNode上的type字段
const selection = figma.currentPage.selection[0];
if (selection.type === "RECTANGLE") {
console.log((selection as RectangleNode).cornerRadius);
}以下类型使用CornerMixin,基于类型插件声明文件:
RectangleNode
EllipseNode
PolygonNode
StarNode
VectorNode
BooleanOperationNodehttps://stackoverflow.com/questions/68897212
复制相似问题