Reputation: 218
I'm getting started with Google Apps scripting, and find the autocomplete very useful. However, once you are inside a new function, autocomplete doesn't seem to have any way of knowing what the type is for the parameter. I've seen some answers about python ideas that say that using javadoc will work. But I'm not able to figure it out. Any suggestions?
function myfunc1(){
var activeSheet=SpreadsheetApp.getActiveSheet();
activeSheet//.autocomplete works here
myfunc2(activeSheet)
}
function myfunc2(myActiveSheet){
myActiveSheet//.autocomplete doesn't work here
}
Upvotes: 2
Views: 1086
Reputation: 8585
The new editor uses JSDoc for parameter types. So declare the parameter in the docs, and specify its type between the braces {}
.
/**
* @param {SpreadsheetApp.Sheet} sheet
*/
function myfunc(sheet) {
sheet //.autocomplete now works here
}
Upvotes: 2
Reputation: 7377
There are limitations to what the UI can do in terms of autocomplete.
Usually I just keep the reference documentation open in another tab and refer to that, but you can also trick the UI into auto completing using comments:
function myfunc2(myActiveSheet){
/*
var myActiveSheet = SpreadsheetApp.getActiveSheet()
*/
myActiveSheet //.autocomplete now works here
}
Upvotes: 6