google 应用程序脚本编辑器中的自动完成并不总是知道 type/context
Autocomplete in google apps script editor not always aware of type/context
我开始使用 Google Apps 脚本,发现自动完成功能非常有用。但是,一旦进入新函数,自动完成功能似乎无法知道参数的类型。我已经看到一些关于 python 想法的答案,这些想法说使用 javadoc 会起作用。但我无法弄清楚。有什么建议吗?
function myfunc1(){
var activeSheet=SpreadsheetApp.getActiveSheet();
activeSheet//.autocomplete works here
myfunc2(activeSheet)
}
function myfunc2(myActiveSheet){
myActiveSheet//.autocomplete doesn't work here
}
UI 在自动完成方面的功能有限。
通常我只是在另一个选项卡中打开参考文档并参考它,但您也可以使用评论欺骗 UI 自动完成:
function myfunc2(myActiveSheet){
/*
var myActiveSheet = SpreadsheetApp.getActiveSheet()
*/
myActiveSheet //.autocomplete now works here
}
参数类型的new editor uses JSDoc。所以在文档中声明参数,并在大括号 {}
.
之间指定其类型
/**
* @param {SpreadsheetApp.Sheet} sheet
*/
function myfunc(sheet) {
sheet //.autocomplete now works here
}
我开始使用 Google Apps 脚本,发现自动完成功能非常有用。但是,一旦进入新函数,自动完成功能似乎无法知道参数的类型。我已经看到一些关于 python 想法的答案,这些想法说使用 javadoc 会起作用。但我无法弄清楚。有什么建议吗?
function myfunc1(){
var activeSheet=SpreadsheetApp.getActiveSheet();
activeSheet//.autocomplete works here
myfunc2(activeSheet)
}
function myfunc2(myActiveSheet){
myActiveSheet//.autocomplete doesn't work here
}
UI 在自动完成方面的功能有限。
通常我只是在另一个选项卡中打开参考文档并参考它,但您也可以使用评论欺骗 UI 自动完成:
function myfunc2(myActiveSheet){
/*
var myActiveSheet = SpreadsheetApp.getActiveSheet()
*/
myActiveSheet //.autocomplete now works here
}
参数类型的new editor uses JSDoc。所以在文档中声明参数,并在大括号 {}
.
/**
* @param {SpreadsheetApp.Sheet} sheet
*/
function myfunc(sheet) {
sheet //.autocomplete now works here
}