Adding DOM gives error in index.js

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

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?

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.

Have you tried searching it on Google?

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.