Skip to content

A companion typescript plugin to tgas-local that enables type checking and autocomplete for your local google apps script repositories.

License

Notifications You must be signed in to change notification settings

seth-aker/typescript-plugin-tgas-local

Repository files navigation

Typescript-plugin-tgas-local

A typescript language server plugin to improve the experience for developing Google Apps Scripts (GAS) locally with typescript. This plugin hooks into the typescript languageServiceHost and injects a virtual type declaration file based on the source directory of your GAS files.

Installation

  1. Install the plugin and dependancies:
pnpm install -D typescript-plugin-tgas-local @types/google-apps-script typescript
  1. Add the following fields to your tsconfig.json
{
  // ...rest of your compilerOptions
  "plugins": [
    {
      "name": "typescript-plugin-tgas-local",
      "apps-script-directory": "./RELATIVE_PATH_TO_YOUR_GAS_FILES"
    }
  ]
}
  1. Important! If using VSCode, set your workspace settings to use the locally installed version of typescript. In this file: project_root/.vscode/settings.json
{
  "typescript.tsdk": "node_modules\\typescript\\lib"
}

How it works

Essentially, the plugin searches your files for the gasRequire() function from tgas-local package. Once it finds that, it generates a type file (.d.ts) based on the top level declarations inside of your GAS files. It then applies those types as the return object of gasRequire()

Links

tgas-local: Run and test GAS code locally with typescript.

About

A companion typescript plugin to tgas-local that enables type checking and autocomplete for your local google apps script repositories.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published