Missing `public` prefix on suggested Convert to Typscript Function?

Hello,

When you look at an action not backed by a Function, there is a ‘Covert TypeScript Function Code’ (Experimental) feature that suggests the equivalent TS code as a starting point for perhaps making a more complex function.

In that suggestion the public keyword is missing before the async functionName(input a, input b). One colleague was, we think, caught out by this, as without the public keyword, it doesn’t look like the Action that’s backed by this function is visible in Foundry, even if it’s correctly published. After we added public and created a new tagged version it was visible. Even without the public it worked in the function preview etc.

All the examples in the docs use the public prefix, but I couldn’t actually see anywhere where it says this is mandatory for the publishing to work. Is it mandatory, and an omission in this conversion suggestion, or is the public not essential to have a function published?

TypeScript marks a member or function of a class as public by default, so this is likely why you are not getting any errors when omitting it.

However, in order for the function to be released, it must explicitly be marked as public in your code. This is a design choice, but one likely made to not expose any functions that aren’t explicitly marked as public.

So to answer your question: It’s mandatory for the publishing, but not required by the language, and it’s not mentioned in the documentation (AFAIK).

1 Like

OK, thanks.

So it’s something that should probably be:

  • Added to the documentation then, and
  • A correction to the TypeScript template that generates the example function for Actions not backed by functions.

Hopefully someone from the relevant teams spots this comment here then.

1 Like

thanks for the feedback. I’ve updated the template to add the public keyword. Should be released in a few days. :slight_smile:

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.