WebStorm (and any JetBrains IDE with the JavaScript plugin) can now handle this automatically by using TypeScript community stubs. The details are in Configuring JavaScript Libraries - Help - WebStorm.
Follow the instructions on that page under To download TypeScript definitions in the Settings/Preferences dialog. Search for the TypeScript community stub named google-apps-script
.
WebStorm will try to guess the type of variables based on the context, but you can also tell it explicitly. For example this tells WebStorm that thread is a GmailThread. So getLabels
could be autocompleted.
/**
* @param {GoogleAppsScript.Gmail.GmailThread} thread
*/
function getThreadInfo(thread) {
thread.getLabels()
}
FYI, You can search for TypeScript community stubs and get more information on each one at https://microsoft.github.io/TypeSearch/.