Skip to content

Diagnostic reference

ReferenceError: GoogleAppsScript is not defined

Why the GoogleAppsScript type namespace fails at runtime, and where it belongs: JSDoc type positions, not values.

Updated September 12, 2026

Apps Script error

ReferenceError: "GoogleAppsScript" is not defined

What it means

GoogleAppsScript is a namespace from the @types/google-apps-script declarations. Apps Script does not define it at runtime. Keep it in type annotations when you use those declarations. myFunction uses service namespaces such as GmailApp.GmailMessage for JSDoc types, as shown below. Runtime code calls service globals such as GmailApp.

Before and after

The code before and after the fix.

Problem 2 changed lines
var GmailMessage = GoogleAppsScript.Gmail.GmailMessage;

function getSubject(message) {
  return message.getSubject();
}
Fixed 3 changed lines
/**
 * @param {GmailApp.GmailMessage} message
 */
function getSubject(message) {
  return message.getSubject();
}

How to fix it

  • Remove the assignment that tries to read GoogleAppsScript at runtime.
  • Keep type references in JSDoc comments or TypeScript annotations.
  • Use the type name provided by your declarations. This example uses myFunction's GmailApp.GmailMessage.

Things to check

  • Type annotations do not change runtime behavior.