I’m working on a basic Figma plugin and running into TypeScript issues. When I try to access properties on selected elements, TypeScript throws errors even though I’ve installed the official type definitions.
My plugin code looks like this:
figma.showUI(__html__);
// Without this ignore comment, TS throws an error
console.log(figma.currentPage.selection[0].borderRadius);
The error I get is: “Property ‘borderRadius’ does not exist on type ‘SceneNode’.”
I installed the Figma types package and my tsconfig.json is set up like this:
The plugin actually works fine when I run it, but I have to use @ts-ignore to suppress the TypeScript warnings. What configuration am I missing to make TypeScript recognize the Figma API types properly?
Your tsconfig.json looks mostly correct, but you’re missing a crucial step in the types declaration. Make sure you have “types”: [“@figma/plugin-typings”] explicitly listed in your compilerOptions. Without this, TypeScript won’t automatically load the Figma plugin types even though they’re installed. I encountered this exact problem when building my first plugin last year. The borderRadius property exists on specific node types like RectangleNode, EllipseNode, and FrameNode, but not on the generic SceneNode interface. After adding the types declaration, you can use proper type narrowing with something like if (node.type === ‘RECTANGLE’) to access type-specific properties without casting.
you gotta remember that borderRadius is specific to certain nodes, like rectangles. try casting it first, like this: (figma.currentPage.selection[0] as RectangleNode).borderRadius. or check its type before trying to access the property.
quick fix - make sure you actually imported the types correctly. sometimes the @figma/plugin-typings dont get loaded even when installed. try adding /// <reference types="@figma/plugin-typings" /> at the top of your main plugin file. worked for me when i had similar issues.
The issue stems from how Figma’s type system works with node hierarchies. SceneNode is the base type that doesn’t include borderRadius since not all scene nodes have that property. Instead of using type casting everywhere, add proper type guards to your code. Check node.type === 'RECTANGLE' or use 'borderRadius' in node before accessing the property. This approach is cleaner than casting and prevents runtime errors if you accidentally select incompatible nodes. Also verify that your @figma/plugin-typings package is the latest version, as older versions had incomplete type definitions for some properties.
I ran into something similar when switching from JavaScript to TypeScript for plugin development. The root cause is that your typeRoots configuration is looking for types in the wrong location. The @figma/plugin-typings package doesn’t install to @figma directory, it goes to the standard @types location. Remove the “./node_modules/@figma” entry from your typeRoots array and just keep “./node_modules/@types”. Also make sure you have the correct package installed - it should be @figma/plugin-typings, not just figma-plugin-api or similar packages that might show up in search results. After fixing the typeRoots, restart your TypeScript language server to pick up the changes properly.