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

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

问题描述

我问了一个问题,并通过答案发现我没有问正确的问题!

I asked a question and through the answer found I had not asked the right question!

LibraryFoo是一个库,如果我在其他地方将该库用作库,则会得到类型完成.例如,如果我有

Say LibraryFoo is a library and if I use that elsewhere as a library, I get type completion. For example, if I have

/**
 *  Lorem ipsum
 *
 *  @return {Object[]}
 *
 */
function bar() {}

LibraryFoo中使用

,如果在其他Google脚本中键入LibraryFoo.bar().,则会得到有关诸如forEachmap之类的数组的建议.但是,如果我有

in LibraryFoo and if in the other Google Script I type LibraryFoo.bar(). I get suggestions for an array like forEach and map. However, if instead I have

/**
 *  Lorem ipsum
 *
 *  @return {Sheet}
 *
 */
function barring() {}

,我键入LibraryFoo.barring().,但没有得到类似getRangegetMaxColumns的建议.我知道使用clasp和本地IDE可能更有意义,但似乎是其中两种:

and I type LibraryFoo.barring(). I do not get suggestions like getRange or getMaxColumns. I know that using clasp and local IDE might make more sense, but one of two seems to be the case:

  1. 我使用了错误的名称/引用(尽管键入Google自己的函数时,它们只是说"Sheet".例如SpreadsheetApp的源代码是否可用?这可能是一个提示,或者不在正确的GAS中).
  2. 这是不可能的,因为Google已经做了我/我们做不到的事情.

尽管如此,尽管搜索并尝试了不同的方式来命名Sheet引用的命名空间,但我还没有发现它是1.还是2.(或其他东西!).

Regardless, despite searching and trying different ways to namespace the Sheet reference, I have not found out whether it is 1. or 2. (or something else!).

推荐答案

注意事项

目前尚无法在Apps脚本编辑器中实现.

This is not currently possible to achieve in the Apps Script Editor.

Google Issuetracker上有一些关于此功能的开放功能请求:

There are a few open feature requests on Google Issuetracker about this:

通过图书馆文档支持面向对象的接口

有关类和方法的完整jsdoc

由于提交了新功能请求,讨论-给它或上面提到的其他元素加注星标,以增加该功能在不久的将来被实施的机会.

There is also a new feature request submitted as a result of the discussion - star it or the other ones mentioned above to increase the chances of the feature being implemented any time soon.

JSDoc在Google Apps脚本中不完全受支持,并且自动补全功能在当前状态下的顶级定义下无法正常工作.这适用于自定义类以及诸如SpreadsheetSheetRange之类的内置类,因为此处的自动完成功能需要第二级迭代.

JSDoc is not fully supported in Google Apps Script, and autocompletion doesn't work further than the top-level definition at the current state. This applies to custom classes and to built-in classes like Spreadsheet, Sheet, Range as the autocompletion here would require a second level iteration.

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

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