TypeScript definitions missing in my Figma plugin project

I set up a basic Figma plugin following the official documentation. My plugin code is simple:

figma.showUI(__html__);

// @ts-ignore
console.log(figma.currentPage.selection[0].borderRadius);

The plugin works perfectly and successfully gets the border radius from the selected element. But when I delete the // @ts-ignore comment, TypeScript throws an error saying “Property ‘borderRadius’ does not exist on type ‘SceneNode’.”

I installed the type definitions as instructed in the setup guide. Here’s my tsconfig.json:

{
  "compilerOptions": {
    "target": "es6",
    "lib": ["es6", "dom"],
    "typeRoots": [
      "./node_modules/@types",
      "./node_modules/@figma"
    ]
  }
}

What could be causing this TypeScript error? Am I missing something in my configuration?

u might be tryin to access borderRadius on a SceneNode, but ts ain’t sure it’s for a rectangle. best to cast it like this: (figma.currentPage.selection[0] as RectangleNode).borderRadius or just check node type before accessin the property.

Yeah, classic TypeScript issue with Figma’s API. Your setup’s fine - you’re just trying to access a property that only exists on certain node types.

I’ve hit this exact problem building internal tools. Instead of manually checking types every time, I automated it with Latenode.

I built a workflow that monitors our Figma files and auto-extracts design tokens like border radius values. Latenode connects to Figma’s API, handles the type checking, grabs what I need, and pushes it straight to our design system database.

No more TypeScript wrestling or writing the same type guards over and over. Runs automatically when designers update components, so tokens stay synced.

You could do the same - have Latenode pull your border radius values and send them wherever you need them. Much cleaner than fighting TypeScript in plugin code.

Check it out: https://latenode.com

This happens because TypeScript doesn’t know what specific node type you’re dealing with. Sure, borderRadius exists on rectangles and frames, but TypeScript only sees the generic SceneNode type - and that doesn’t guarantee the property exists. I ran into this same issue with my first plugin. Best fix is adding a type guard before you access the property: const node = figma.currentPage.selection[0]; if (‘borderRadius’ in node) { console.log(node.borderRadius); } No casting needed, and it handles cases where users select the wrong elements. Your type definitions are fine - TypeScript’s just doing its job by catching potential runtime errors.

The TypeScript definitions are working fine - that’s how they’re supposed to work. SceneNode is the base interface, but borderRadius only exists on specific nodes like rectangles and frames. I’ve hit this tons of times building plugins for our design team. Don’t disable strict mode or use optional chaining. Instead, combine type narrowing with error handling: const selection = figma.currentPage.selection[0]; if (selection && 'borderRadius' in selection) { console.log(selection.borderRadius); } else { console.log('Selected node does not have borderRadius property'); } This stops runtime errors when users select the wrong elements and gives them actual feedback instead of silent failures.

The error occurs because the borderRadius property is specific to nodes like RectangleNode, EllipseNode, and FrameNode, rather than the generic SceneNode interface. When you access selection[0], TypeScript interprets it as a SceneNode, which lacks the borderRadius property. I faced a similar issue when I started with my plugin as well. The ideal solution is to check the type of the node: if (figma.currentPage.selection[0].type === ‘RECTANGLE’) { const rect = figma.currentPage.selection[0] as RectangleNode; console.log(rect.borderRadius); }. This approach ensures you avoid cases where users may select text nodes or other types without that property, rather than simply casting it. Your tsconfig.json setup looks good - TypeScript is just maintaining its type safety.

your tsconfig looks fine. add "strict": false to compilerOptions if u want looser type checking. or just use optional chaining like figma.currentPage.selection[0]?.borderRadius - though that’ll return undefined for non-rectangle nodes.