google-apps-scriptidejsdoc

How to type hint Google Types in Google Scripts?


I am trying to typehint a bunch of javascript in Google Script, and I have gotten as far as trying this:

/**
 *  Get (named) range given by name
 *
 *  @param {String} name 
 *  @return {Range}
 *
 */
function getRange(name) {
  return SpreadsheetApp.getActiveSpreadsheet().getRangeByName(name);
}

Which displays well and gives the same typehint as the builtin getRangeByName, however it does not actually work, i.e. the auto-complete script editor does not autocomplete when I type something like getRange("hello").get", like it should. Should I be name spacing the Range or am I doing something else wrong?


Solution

  • The current Google Apps Script IDE doesn't use local JSDOC to extend the autocomplete feature. Options:

    1. Create a Goole Apps Script library and attach it to your project
    2. Use another IDE

    Regarding using another IDE at this time there is a tool called CLASP that helps to download/upload script which make it possible to use other IDEs.

    Resources

    Related

    Other related