Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to enable autocomplete for Google Apps Script in locally-installed IDE

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

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.

The documentation says:

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

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.

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.

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

like image 875
Anton Dementiev Avatar asked Feb 27 '18 18:02

Anton Dementiev


People also ask

How do I enable Google scripts?

In the script editor, select Resources > Advanced Google services.... In the Advanced Google Service dialog that appears, click the on/off switch next to the service you want to use. Click OK in the dialog.

Is Google Apps Script an IDE?

We've redesigned the Integrated Development Environment (IDE) for Google Apps Script. The new IDE offers a more modern and simplified development experience which makes it quicker and easier to build solutions that make Google Workspace apps more useful for your organization.


1 Answers

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. Install the NPM package containing type definitions for GAS using

    https://www.npmjs.com/package/@types/google-apps-script 
  2. In your locally-saved script, create a '.js' file and type

    import 'google-apps-script'; 
like image 187
Anton Dementiev Avatar answered Sep 18 '22 13:09

Anton Dementiev