However, whenever I setup Typescript compilation (as per the guide here: Plugin Quickstart Guide | Plugin API), my code.js file is replaced. From what I can tell, it is replaced by what is in code.ts.
At the same time, if I copy and paste my code from code.js into code.ts, I get errors.
Is this going to be a problem when I go ahead and officially launch the plugin? So for example, if I have functioning code in code.js, and I then submit the plugin, will that code get replaced by what is in code.ts?
Manifest.json, code.js and ui.html files are sent to Figma.
If you don’t use TypeScript, why do you need code.ts at all?
I guess this exception in
code.js is supposed to let you know that file will get overwritten during the build process:
throw new Error("This plugin template uses TypeScript. Follow the instructions in `README.md` to generate `code.js`.")
I really think Figma made plugins unnecessarily complicated by making TypeScript a default part of the plugin docs and guides. If you just want to use JS, put everything in the
code.js file and get rid of
code.ts. You don’t need to run any build step at all if all the code is in one file and you don’t care about minification.