Skip to main content
Question

Adding DOM gives error in index.js

  • February 9, 2023
  • 3 replies
  • 913 views

Nidhin_Kuttikkattu_Rajeevan

Hi I have
Version 4.9.5 of typescript

In my figma plugin, I did
npm install -g typescript
npm install --save-dev @figma/plugin-typings

And my plugin worked fine.

As in this link

figma.com

I need to add TextDecoder for SVG export. It says, for TextDecoder, I need to add DOM to tsconfig.json.

I added it.

After that, index.js complains…

const console: Console
Cannot redeclare block-scoped variable ‘console’.ts(2451)

Cannot redeclare block-scoped variable ‘fetch’.ts(2451)

View Problem (Alt+F8)
const fetch: (url: string, init?: FetchOptions) => Promise

How to fix this?

This topic has been closed for replies.

3 replies

I’ve got the same problem - exporting svg and getting the error "Cannot find name ‘TextDecoder’, and then adding ‘dom’ to ‘lib’ in tsconfig and then getting two conflict errors in @figma plugin-typings: console and fetch.


tank666
  • 4873 replies
  • March 20, 2023

Have you tried searching it on Google?

stackoverflow.com

I have - and it brought me here!

However, I had a look at this solution - the latest from 2022 is to include
"moduleDetection": "force"
in tsconfig.json compilerOptions.

Unfortunately this still doesn’t work as I now have:

figma_app.min.js.br:5 Syntax error on line 34: Unexpected token export {};

It seems that the earlier workaround to add “export {}” manually has been replaced with a flag that adds it for you. Either way manually or otherwise, it still doesn’t work.


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