How to declare function in code.ts

Hi, I’m trying to create a helper function inside code.ts of my plugin like so:

However, I’m getting the error “cannot find the name updateUI” even though I’ve declared the function. Could someone please explain why this is not working?

[EDIT]: just declare void function without the void keyword and it’ll work!
Screenshot 2023-06-27 at 10.06.51 AM

To make my code more manageable, I decided to create an external file called helper.ts and imported the function in my code.ts like so:
Screenshot 2023-06-26 at 5.12.37 PM

In order for this to work, you have to set up your plugin project to allow code.ts to import external files (which is blocked by default due to Figma’s CSP). You can refer to this article on doing so using Webpack: Libraries and Bundling | Plugin API

Regarding the initial question, the issue is you wrote void before function. This is not valid JS/TS syntax therefore it is not working. You don’t necessarily have to put it in another file.

you’re right! I’ll edit my first post to reflect that!