如何在Google脚本中键入提示Google类型? [英] How to type hint Google Types in Google Scripts?

查看:114
本文介绍了如何在Google脚本中键入提示Google类型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在Google脚本中键入一堆JavaScript,而我已经尝试了以下方法:

I am trying to typehint a bunch of javascript in Google Script, and I have gotten as far as trying this:

/**
 *  Get (named) range given by name
 *
 *  @param {String} name 
 *  @return {Range}
 *
 */
function getRange(name) {
  return SpreadsheetApp.getActiveSpreadsheet().getRangeByName(name);
}

可以很好地显示并提供与内置getRangeByName相同的typehint,但是它实际上不起作用,即,当我键入getRange("hello").get"之类的东西时,自动完成脚本编辑器不会自动完成,就像应该这样.我应该用Range隔开还是要做其他错误的事情?

Which displays well and gives the same typehint as the builtin getRangeByName, however it does not actually work, i.e. the auto-complete script editor does not autocomplete when I type something like getRange("hello").get", like it should. Should I be name spacing the Range or am I doing something else wrong?

推荐答案

当前的Google Apps脚本IDE不使用本地JSDOC来扩展自动完成功能.选项:

The current Google Apps Script IDE doesn't use local JSDOC to extend the autocomplete feature. Options:

  1. 创建一个Goole Apps脚本库并将其附加到您的项目中
  2. 使用其他IDE

关于当前使用另一个IDE,有一个名为CLASP的工具可以帮助下载/上传脚本,从而可以使用其他IDE.

Regarding using another IDE at this time there is a tool called CLASP that helps to download/upload script which make it possible to use other IDEs.

资源

  • https://developers.google.com/apps-script/guides/libraries
  • https://developers.google.com/apps-script/guides/clasp

相关

  • Google Apps Script Auto Generated Library Documentation
  • Is it possible to get the autocomplete functionality in AppsScript's script editor to work on custom classes?
  • How do I get a suggestions?

其他相关

这篇关于如何在Google脚本中键入提示Google类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆