3

I see that Apps Script uses a lot of enums, predefined by Google (e.g. Enum MimeType).

How can I define my own Enum types so they are shown on my own libraries?

I can add a standard enum like this.

var size = {
  SMALL: 1,
  MEDIUM: 2,
  LARGE: 3,
};

var mySize = size.MEDIUM;

and it works properly, but if I add my project as a library, the enum is not listed as a standard enum, but as an object type:

Enum shown as object

Any ideas?

tehhowch
  • 9,645
  • 4
  • 24
  • 42
  • You can use size as an enum as long as it is in global scope and you precede with the namespace, for example MyLibrary.size.MEDIUM – TheWizEd Mar 20 '19 at 18:28
  • Read about documenting your scripts with JSDoc for autocompletion – tehhowch Mar 20 '19 at 19:04
  • I've used JSDoc convention as shown here: http://usejsdoc.org/tags-enum.html but still get a "object" and not enum type (and autocompletion does not work). – José Ángel Morente Mar 20 '19 at 22:40
  • https://stackoverflow.com/questions/14893927/writing-jsdoc-documentation-on-methods-inside-a-class https://stackoverflow.com/questions/15158745/google-apps-script-auto-generated-library-documentation https://developers.google.com/apps-script/guides/libraries#best_practices (note that only `@param` and `@returns` have stated support. Consider developing locally with typescript and using a third party tool to bundle your library code directly – tehhowch Mar 20 '19 at 23:10

0 Answers0