如何在本地安装的 IDE 中为 Google Apps 脚本启用自动完成功能 [英] How to enable autocomplete for Google Apps Script in locally-installed IDE

查看:32
本文介绍了如何在本地安装的 IDE 中为 Google Apps 脚本启用自动完成功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 clasp 在本地构建 GAS 项目.

I'm trying to build GAS projects locally using clasp.

任何本地安装的 IDE 都是对 Google 的脚本编辑器的巨大改进,因此该工具看起来非常有前途.不幸的是,GAS 服务的自动完成功能似乎没有包含在包中.

Any locally-installed IDE is a huge improvement over Google's Script Editor, so the tool looks very promising. Unfortunately, the autocomplete feature for GAS services doesn't seem to be included in the package.

文档说:

Apps Script CLI 使用 TypeScript 在开发时提供自动完成和 linting.使用 Visual Studio Code 等 IDE 进行 TypeScript 自动补全.

The Apps Script CLI uses TypeScript to provide autocompletion and linting when developing. Use an IDE like Visual Studio Code for TypeScript autocompletion.

在完成这些步骤并安装所有必需的依赖项后,我仍然无法使用自动完成功能.当我为现有项目执行 clasp pull 命令时,它会将.gs"扩展名转换为.js".自动完成建议只是解析现有代码的结果.

After going through the steps and installing all required dependencies, I'm still unable to get the autocomplete feature to work. When I execute the clasp pull command for the existing project, it converts the ".gs" extension to ".js". The autocomplete suggestions are simply the result of parsing existing code.

例如,如果我在代码中的某处调用 sheet.getRange(),那么 getRange() 方法将在建议中弹出,但我不能列出例如 PropertiesService 的可用选项,除非它已在我的代码中使用.

For example, if I call sheet.getRange() somewhere in my code, then the getRange() method will pop up in suggestions, but I can't list available options for, say, PropertiesService, unless it's already used in my code.

有没有人为 Google Apps 脚本启用自动完成功能?

Has anybody had any luck with enabling autocomplete feature for Google Apps Script?

推荐答案

我找到了部分有效的解决方案,但它可能不适用于其他软件.以下步骤适用于 Visual Studio Code:

I found the solution that partially works, but it may not be applicable to other software. The steps below are for Visual Studio Code:

  1. 使用

https://www.npmjs.com/package/@types/google-apps-script

  • 在本地保存的脚本中,创建一个.js"文件并输入

  • In your locally-saved script, create a '.js' file and type

    import 'google-apps-script';
    

  • 这篇关于如何在本地安装的 IDE 中为 Google Apps 脚本启用自动完成功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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