Figma ts Unexpected token error

Simple code:

let newPage: PageNode = figma.createPage();


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


"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?

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.

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.