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 used by @types/google-apps-script declarations; Apps Script does not define it as a runtime value. Keep it in type annotations when using 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
See the change before you make it.
var GmailMessage = GoogleAppsScript.Gmail.GmailMessage;
function getSubject(message) {
return message.getSubject();
}/**
* @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.
What stays with you
- Type annotations do not change runtime behavior.
- myFunction does not transpile or bundle the project.
Related reading