Skip to content

Diagnostic reference

TypeError: X is not a function

Why Apps Script throws 'X is not a function': tell a misspelled method from a method called on the wrong object, then use the declared replacement.

Updated September 12, 2026

Apps Script error

TypeError: sheet.hideGridlines is not a function

What it means

The code calls a method that does not exist on that object. Either the name is misspelled, or a real method is being called on the wrong Apps Script class. Apps Script classes expose only their declared methods, so a plausible-looking name like hideGridlines still fails at runtime when the declaration says setHiddenGridlines.

Related error messages

  • TypeError: output.setHeader is not a function
  • TypeError: item.setShuffleOrder is not a function
  • TypeError: ss.newChart is not a function

Before and after

See the change before you make it.

Problem
function hideLines() {
  const sheet = SpreadsheetApp.getActiveSheet();
  sheet.hideGridlines();
}
Safer version
function hideLines() {
  const sheet = SpreadsheetApp.getActiveSheet();
  sheet.setHiddenGridlines(true);
}

How to fix it

  • Check which class the preceding call returns: getActiveSheet() returns a Sheet.
  • Replace hideGridlines() with the documented Sheet.setHiddenGridlines(true) call.
  • Confirm the boolean argument matches the formatting you want.

What stays with you

  • Confirm the replacement matches the intended behavior; near-names sometimes do different things.
  • myFunction does not run the script or change sheet formatting by itself.