I’m working on building a Figma plugin using TypeScript and running into compilation problems. When I try to compile the project in my development environment, I keep getting syntax errors that prevent the build from completing successfully. The error messages indicate there’s an unexpected token somewhere in the code, but I’m having trouble pinpointing exactly where the issue is occurring. I’ve double-checked my TypeScript configuration and syntax, but the compilation process still fails. Has anyone encountered similar TypeScript compilation errors when developing Figma plugins? I’m looking for guidance on common causes of these syntax errors and how to resolve them. Any tips for debugging TypeScript compilation issues in the context of Figma plugin development would be really helpful.
check your package.json deps - had issues with conflicting @figma/plugin-typings versions. sometimes errors aren’t where they appear. try running tsc --noEmit to see all errors at once, rather than stopping at the first one. also, don’t mix commonjs and es6 imports.
This happens when your build environment doesn’t match what Figma expects. I see this a lot with arrow functions - Figma’s plugin environment is picky about function declarations vs expressions. Another common issue is using newer JavaScript features that weren’t transpiled properly. Try changing your tsconfig.json to target ES5 instead of ES6+ and see if that fixes it. Also check if you’re importing Node.js modules that don’t work in the plugin sandbox. Figma plugins need specific webpack loaders for TypeScript, so make sure your build pipeline is set up for plugins, not regular web apps.
Had the exact same problem with my Figma plugin. Turned out my TypeScript version didn’t play nice with Figma’s API. Fixed it by downgrading to TypeScript 4.7 - newer versions use syntax that Figma can’t handle. Also check your tsconfig.json targets ES2017 and has moduleResolution set to node. I got weird errors from using async/await in places where Figma’s API didn’t expect it. If you’re still stuck, try commenting out code sections one by one to find what’s breaking.