Reputation: 6984
function onEdit(e)
e... //I want auto completion
var range = e.range();
e.... //I want auto completion
}
How to force auto completion on a variable such as in onEdit, is there a way to explicitly specify what type e is for the purposes of auto completion?
Upvotes: 2
Views: 399
Reputation: 19339
As others already said in comments, you cannot use autocomplete for event objects using Apps Script editor.
The workaround, then, also as referenced by other users, would be to use clasp and work with an IDE with which you can enable autocomplete.
Upvotes: 1
Reputation: 76
In the new Apps Script IDE you can use JSDoc for auto completion with built-in types.
/**
* Clears the content of the range, leaving the formatting intact.
* @param {SpreadsheetApp.Range} range The range to clear the content
* @return {SpreadsheetApp.Range} This range, for chaining.
*/
function clearContent(range) {
range.clearContent()
}
The Event object doesn't appear to have a built-in declaration, but you can always create your own.
/**
* @typedef {Object} onEditEvent
* @property {ScriptApp.AuthMode} authMode A value from the ScriptApp.AuthMode enum.
* @property {string} oldValue Cell value prior to the edit, if any. Only available if the edited range is a single cell.
* Will be undefined if the cell had no previous content.
* @property {SpreadsheetApp.Range} range A Range object, representing the cell or range of cells that were edited.
* @property {SpreadsheetApp.Spreadsheet} source A Spreadsheet object, representing the Google Sheets file to which the script is bound.
* @property {string} triggerUid ID of trigger that produced this event (installable triggers only).
* @property {User} user A User object, representing the active user, if available (depending on a complex set of security restrictions).
* @property {string} value New cell value after the edit. Only available if the edited range is a single cell.
*/
/**
* @param {onEditEvent} e The onEdit event.
*/
function onEdit(e) {
e... // type to show autocomplete
}
Upvotes: 6