Enabling autocomplete for Google Apps Script in locally-installed IDE

ぃ、小莉子 提交于 2019-11-28 06:02:38

I found the solution that kind of 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

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';

The only issue is imports must be removed before pushing updates to the server.

This answer is a minor variation on the accepted one for other IDEs:

  • Install TypeScript and @types/google-apps-script

  • Create a jsconfig.json file in your local project directory:

    { 
        "compilerOptions": {
            "checkJs": true
          }
    }    
    
  • Alternatively, If you're using typescript along with javascript, then create a tsconfig.json:

    { 
        "compilerOptions": {
            "allowJs": true,
            "checkJs": true,
            "types": ["google-apps-script"]
          }
    }    
    
  • Include both filenames in .claspignore, if you're using clasp and if the file is in your local directory.

  • You can also use any of this config globally, if the config is in your home/parent directory, as tsc searches for this config from project/local folder to root(in which case, you don't need to include it in .claspignore).

meleu

How about:

Including the file name (e.g. import.js) in .claspignore.

This should save some hassle deleting the file before each push every time.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!