Skip to main content
Question

Figma ts Unexpected token error


edDes

Simple code:

let newPage: PageNode = figma.createPage();

Error:

vendor-core-67cd853d…3a53b1.min.js.br:15 Syntax error on line 36: Unexpected token :
            let newPage: PageNode = figma.createPage();

package.json

"scripts": {
    "build": "tsc -p tsconfig.json",
    "lint": "eslint --ext .ts,.tsx --ignore-pattern node_modules .",
    "lint:fix": "eslint --ext .ts,.tsx --ignore-pattern node_modules --fix .",
    "watch": "npm run build -- --watch"
  },

What is going on here?

This topic has been closed for replies.

3 replies

I don’t know I this helps in any way - but I was getting the same error. For me it turned out that Figma plugins (on Sonoma 14.5, Figma 124.2.8 no longer likes console logs. When I removed them - that error removed and all ran as expected. May not be the same issue though.


Gleb
  • Power Member
  • 4710 replies
  • July 13, 2024

You are feeding it raw TS code but you need to compile it first. Make sure your manifest points to a .js file not a .ts file. And that js file needs to be compiled using the build command.


edDes
  • Author
  • 3 replies
  • July 16, 2024

Correct, fixed, and thanks to @Gleb.

I am not sure where this code.ts came from in the manifest, but changing it solved the issue.


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings