1

I have the following code

var Top = (function () {

  var LevelA = (function () {

    var LevelA1a = (function () {
      const method1 = () => { return 'Hello from LevelA1a.method1' }
      const method2 = () => { return 'Hello from LevelA1a.method2' }
      return {
        method1: method1,
        method2: method2
      }
    }()); // LevelA1a

    var LevelB1b = () => { return 'Hello from LevelB1b' }

    return {
      LevelA1: LevelA1a,
      LevelB1: LevelB1b
    }
  }()); // LevelA

  var LevelB = () => { return 'Hello from LevelB' }

  return {
    LevelA: LevelA,
    LevelB: LevelB
  }

}());

When this code is included directly in my script it behaves exactly as I want it aka every time I press the dot the editor suggest me the next level. When this code is included in another script the editor stops suggesting after the first level (Top). How can I structure my code to have the direct included behavior when it is included as library?

Employed Russian
  • 199,314
  • 34
  • 295
  • 362
  • If [this](https://stackoverflow.com/a/75088290/17926478) answered your question, please click the accept button on the left (check icon). By doing so, other people in the community, who may have the same concern as you, will know that theirs can be resolved. If the accept button is unavailable to you, feel free to tell me. [How to accept answer](https://stackoverflow.com/help/accepted-answer) – Lorena Gomez Jan 13 '23 at 21:05

1 Answers1

0

Currently only top level functions will autocomplete in Apps Script libraries.

Only enumerable global properties are visible to library users. This includes function declarations, variables created outside a function with var, and properties explicitly set on the global object.

This is a product limitation for Google Apps Script libraries and has been promoted for future development, you can vote for the request through here.

References:

Best practices when writing a library

Lorena Gomez
  • 1,946
  • 2
  • 4
  • 11