Apps Script Autocomplete with JSDoc
2 min readAug 10, 2023
How about autocomplete options for your app script methods? I was interested in using JSDoc. If you add a separate gs
file with the code below, you may use it with autocomplete, like this:
I’ve created a repo file to collect types there.
Sample type:
// Represents the options for an HTTP request.
// https://developers.google.com/apps-script/reference/url-fetch/url-fetch-app#getrequesturl,-params
/**
* @typedef {Object} UrlFetchRequest
* @property {string} url
* @property {string} contentType - The content type, e.g., 'application/xml; charset=utf-8'.
* @property {Object.<string, string>} headers - JavaScript key/value map of HTTP headers.
* @property {string} method - HTTP method: get, delete, patch, post, put.
* @property {string | number[] | Blob | Object.<string, (string | Blob)>} payload - The POST body; string, blob, or object.
* @property {boolean} validateHttpsCertificates - If false, ignores invalid certificates.
* @property {boolean} followRedirects - If false, doesn't auto-follow HTTP redirects.
* @property {boolean} muteHttpExceptions - If true, doesn't throw on failure.
* @property {boolean} escaping - If false, no URL character escaping.
*/
Usage
/** @type {UrlFetchRequest} */
var request = {
}
Other cases
If we want, we may also add types for event objects for:
onEdit
doGet
+doPost
onFormSubmit
and others.
See also types for Telegram Bot by 💪🏼Alex Ivanov. And go “to infinity and beyond” with JSDoc tips by 🦸🏼Tanaike.
Homework
Give me some useful types, please.