Use the myFunction editor extension
Install the myFunction Chrome extension, review what it can access, and use its diagnostics, navigation, and formatting on a small Sheets project.
Install myFunction, explain its browser permissions, and use diagnostics, hovers, navigation, rename, formatting, the command palette, and the outline to fix a broken request counter before running it.
The Apps Script editor reports many mistakes only when a function runs and fails. myFunction is a Chrome extension that checks your code while you type in that same editor. Install the extension, review what it can access, and repair a request counter with four mistakes. You need a Google account that can open the Apps Script editor and a disposable spreadsheet.
The extension changes only the editor. It does not run your script, change how Apps Script executes it, or add OAuth scopes to your project. Authorization, execution identity, and quotas work the same way with or without it.
Install the extension and review its access
Install myFunction from its Chrome Web Store listing. The store lists it as Error Checker for Google Apps Script. The extension requires Chrome 116 or later.
Open the store listing and click Add to Chrome.
Read the permission prompt Chrome shows, then confirm only if you accept it.
Reload any Apps Script editor tab that was already open, so the extension can attach to it.
Before you install any extension, check what it asks for. myFunction's manifest requests these Chrome permissions:
| Permission | What myFunction uses it for |
|---|---|
alarms | Schedules background work, such as sending batched feature-use counts every 30 minutes, without keeping the service worker running. |
identity | Starts Google sign-in when you choose Sign in with Google. |
offscreen | Runs the language service in an offscreen extension document. |
sidePanel | Shows sign-in, plan, and billing in Chrome's side panel. |
storage | Keeps the session, the cached Apps Script declaration library, and local usage counters. |
The Chrome permissions list describes each of these as access to the matching chrome.* API. The manifest also requests host access to two origins. Host access lets an extension run on, or send requests to, the listed sites:
https://script.google.com/*: the extension's content scripts run on Apps Script pages. They read the text of the files open in the editor so the language service can check them. They also add markers, hovers, and edits to the editor when you ask for them.https://api.myfunction.dev/*: myFunction's own service. The extension downloads the Apps Script declaration library from it and uses it for sign-in, subscription status, aggregate usage counts, and error reports. Before it sends an error report, the extension replaces script IDs, email addresses, and tokens in the message and stack trace with placeholders.
Signing in requests your Google account identifier, email address, and basic profile. It does not request the Apps Script API scope or any Gmail, Drive, or Calendar scope, according to the myFunction permissions page. The language service that checks your code runs in your browser. Fix with AI, Add JSDoc types with AI, and Explain with AI are the exceptions. They send the script ID, the file name, the code around the problem, and the diagnostic's code, message, and position to myFunction's service, and that service returns a proposed edit, JSDoc annotation, or explanation.
The extension works with the files loaded in an open Apps Script editor tab. It changes code only through the editor, and only when you choose a fix, rename, format, or refactor, or turn on format on save. Saving remains your action.
What works without an account
Completion, diagnostics, hovers, signature help, navigation, rename, formatting, refactors, inlay hints, quick open, deterministic quick fixes, and the outline do not require sign-in. Diagnostics run as you edit and do not count against any allowance.
Sign in with Google to use Fix with AI, Add JSDoc types with AI, and Explain with AI up to 5 times a month at no cost. A request counts once it reaches the AI service, even if it fails. myFunction Pro removes the monthly limit. The myFunction website lists the current price.
Sign-in, your free AI allowance, and upgrading live in Chrome's side panel. To open it, click the myFunction toolbar icon (Open myFunction) or click the Sign in button (Signed in once signed in) in the myFunction editor panel header. The side panel also has a Show problems in editor button that opens the Problems tab in the editor.

Set up the sample project
Use a disposable spreadsheet so that nothing in this chapter touches real data.
Create a blank Google Sheet and name a tab
Requests.Type
ID,Title, andStatusinA1:C1. Add two or three fictional rows below. Give at least one row the statusDone.Open Extensions > Apps Script. Replace
Code.gswith the file below.In Project Settings, enable Show "appsscript.json" manifest file in editor. Replace
appsscript.jsonwith the manifest below and save both files.
const REQUESTS_SHEET = 'Requests';
const STATUS_COLUMN = 3;
/**
* Returns the bound spreadsheet's Requests sheet or stops with a clear error.
*
* @returns {SpreadsheetApp.Sheet}
*/
function getRequestsSheet_() {
const sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(REQUESTS_SHEET);
if (sheet === null) {
throw new Error('Add a sheet tab named ' + REQUESTS_SHEET + ' before running this function.');
}
return sheet;
}
/**
* Reads the request rows below the header. Returns an empty array when the
* sheet has only a header row.
*
* @param {SpreadsheetApp.Sheet} sheet
* @returns {unknown[][]}
*/
function readRequestRows_(sheet) {
const lastRow = sheet.getLastRow();
if (lastRow < 2) {
return [];
}
return sheet.getRange(2, 1, lastRow - 1, STATUS_COLUMN).getValues();
}
/**
* Logs the title of every request row.
*
* @returns {void}
*/
function logRequestTitles() {
const rows = readRequestRows_(getRequestsSheet_());
rows.forEach(function (row) {
Logger.log(row[1]);
});
}
/**
* Logs how many requests are not Done.
*
* This function contains four mistakes. Open it in the Apps Script editor
* with myFunction installed, then fix each one by reading the Problems panel.
*
* @returns {void}
*/
function countOpenRequests() {
const sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(REQUESTS_SHEET);
const lastRow = sheet.getLastRow();
const rows = sheet.getRange(2, 1, lastRow - 1, '3').getValues();
const open = rows.filter(function (row) {
return row[STATUS_COLUMN - 1] !== 'Done';
});
Logger.log('Open requests: ' + open.lenght);
}
{
"timeZone": "Etc/UTC",
"dependencies": {},
"exceptionLogging": "STACKDRIVER",
"runtimeVersion": "V8",
"oauthScopes": [
"https://www.googleapis.com/auth/spreadsheets.currentonly"
]
}
The manifest requests spreadsheets.currentonly, which permits reading and editing this spreadsheet. The code only reads cells and writes to the execution log. When you run a function, it executes as you, with your authorization, as described in the runtime chapter.
getRequestsSheet_ and readRequestRows_ are working helpers, and logRequestTitles uses them correctly. countOpenRequests contains four mistakes. Do not run it yet.
Find mistakes with diagnostics
When the extension attaches, it adds three controls to the Apps Script toolbar, the row with Undo, Save, Run, and Debug:
A Files button at the left end hides or shows the Files column, which gives the code more room.
Error, warning, and suggestion counts. Click them to open the Problems tab.
A panel button at the right end opens or closes the myFunction panel.
If the editor has no toolbar, a floating badge with the same counts appears in the bottom-right corner instead.
The myFunction panel docks on the right side of the editor and pushes the code aside instead of covering it. Its top bar holds the Problems and Outline tabs, the Sign in (Signed in once signed in) button, a Command palette button, and a close button. Press Alt+Shift+M or click the close button to hide the panel.
Problem code gets a squiggly underline. Hover over an underline to read the message.
For this project the Problems tab lists five findings in countOpenRequests:
| Line | Severity | Message |
|---|---|---|
| 54 | Warning | 'sheet' is possibly 'null'. |
| 55 | Warning | 'sheet' is possibly 'null'. |
| 55 | Error | Argument of type 'string' is not assignable to parameter of type 'number'. |
| 55 | Warning | lastRow - 1 is 0 or less when the sheet has 1 row or fewer, and getRange() then throws "The number of rows in the range must be at least 1." Return early when lastRow is 1 or less. |
| 59 | Error | Property 'lenght' does not exist on type 'unknown[][]'. Did you mean 'length'? |
The language service reports these five messages. Your Problems tab can list them in a different order. For the full catalog of rules and quick fixes the language service runs, see diagnostic rule coverage.

The screenshot shows another sample project in the Problems tab:
Problems are grouped by file, each with its line and column. Click a problem to move the cursor to it.
Click a severity pill (1 error, 1 warning, 1 suggestion) or type in Filter by message, file, or line (/) (press
/in the tab to focus it) to narrow the list.Safe single-file fixes, such as a spelling correction, show a one-click Fix button right on the problem row to apply the edit immediately.
Expand 1 fix (or Fix options) to inspect all actions on a problem. Clicking a code fix opens a Fix preview of the diff with Apply fix and Cancel, or Review in editor when an edit spans multiple files. Fixes marked Review required change control flow, rewrite a loop, or insert placeholder arguments, so check the diff before applying them. The expanded section also shows guidance notes such as Read the range once with getValues(), plus Fix with AI, Add JSDoc types with AI, and Explain with AI when signed in (Sign in to use AI while signed out).
Fix the missing-sheet case
The runtime chapter showed what happens when a chained call assumes a value exists. getSheetByName returns null when no tab has that name. Calling getLastRow() on null stops the execution with a TypeError (see Cannot read properties of null (reading 'getRange')).
The warning 'sheet' is possibly 'null' is that same mistake, found before a run. To fix it, replace the lookup with the helper that already handles the missing tab:
const sheet = getRequestsSheet_(); Both null warnings disappear, because getRequestsSheet_ either returns a sheet or throws Add a sheet tab named Requests before running this function.
Fix the wrong argument type
getRange(2, 1, lastRow - 1, '3') passes the text '3' where numColumns expects a number. The diagnostic underlines '3'. Replace it with the constant the rest of the file uses:
const rows = sheet.getRange(2, 1, lastRow - 1, STATUS_COLUMN).getValues(); Fix the misspelled property
The values chapter warned that reading a misspelled property gives undefined instead of an error. Here, open.lenght would log Open requests: undefined. The diagnostic suggests length. Put the cursor on lenght, open the quick-fix menu with the lightbulb or Ctrl+. (Cmd+. on macOS), and choose Change spelling to 'length'.
Guard the header-only sheet
One warning remains, on lastRow - 1. The code matches the Apps Script declarations, but if the Requests tab has only a header row, lastRow - 1 is 0. Calling getRange with zero rows fails when the function runs (see The coordinates or dimensions of the range are invalid). readRequestRows_ already returns an empty array in that case. Replace the lookup and the read with the helpers:
function countOpenRequests() {
const rows = readRequestRows_(getRequestsSheet_());
const open = rows.filter(function (row) {
return row[STATUS_COLUMN - 1] !== 'Done';
});
Logger.log('Open requests: ' + open.length);
} The Problems tab is now empty for Code.gs. An empty list means the code matches the Apps Script declarations and avoids the mistakes myFunction checks for. It does not show whether the function succeeds with your data. Save, select countOpenRequests, and click Run. Review and approve the authorization prompt for this practice spreadsheet. The execution log shows the number of rows whose status is not Done.
Read the docs while you type
Type SpreadsheetApp. on a new line inside a function. The completion list shows the service's methods with their signatures and descriptions. Keep typing to filter, then press Enter or Tab to insert a name. Inside the parentheses of a call, signature help shows the parameter you are filling in.
Hover over getSheetByName in getRequestsSheet_. The hover shows the declaration, getSheetByName(name: string): SpreadsheetApp.Sheet | null, the method's description, and a See: link to the Apps Script reference page. The | null in the return type is what caused the warnings you fixed. Checking a return type in a hover before you chain another call can reveal a missing-value bug before you run the script.
Type /** above a function and press Enter to insert a JSDoc template. The helpers in the sample use JSDoc @param and @returns tags. The language service reads those tags. Because readRequestRows_ declares @param {SpreadsheetApp.Sheet} sheet, the language service also reports a call that passes it a possibly null value.
Trigger and web app entry points include onEdit(e), onOpen(e), doGet(e), doPost(e), and functions named in a ScriptApp.newTrigger() call. For these functions, the quick-fix menu also offers Type 'e' as Events.SheetsOnEdit (or the matching Events.* type) without using AI. Choosing that quick fix inserts a JSDoc @param tag with that Events.* type, so e.range and e.source have completions and type checking inside the handler.
Annotate trigger handlers with the matching Apps Script event type so the editor knows which properties exist on e. For a Sheets edit trigger, write /** @param {GoogleAppsScript.Events.SheetsOnEdit} e */ above function onEdit(e). That tag gives completions for e.range, e.source, and e.value, and it flags e.range() call mistakes (TypeError: e.range is not a function) before you test an edit in Sheets.
Go to definitions, including built-in declarations
Put the cursor on getRequestsSheet_ inside logRequestTitles and press F12, or right-click and choose Go to Definition. The cursor moves to the helper's declaration. If the definition is in another file of the project, myFunction opens that file.
Now try Go to Definition or Peek Definition on getValues. Built-in services have no source file in your project, so myFunction opens a read-only excerpt of the Apps Script declaration library instead. Peek Definition shows it inline below the current line, so you can check a return type without leaving your place.
For getValues(), it shows unknown[][], an array of rows that each hold one value per column, as the batching chapter explained. Check that shape before you index into the result.
Rename a function and find its references
The functions chapter noted that every .gs file shares one global scope. Renaming a helper by search and replace can miss a call in another file, or change an unrelated name that happens to match.
Put the cursor on readRequestRows_ and press Shift+F12 to list its references. You see the declaration and the two calls, one in logRequestTitles and one in your fixed countOpenRequests.
Press F2 on the same name, type readRequestTable_, and press Enter. myFunction renames the declaration and every reference across the project's files. It refuses a new name that is not a valid JavaScript name. For a name that comes from Apps Script, such as getValues, it shows Only names declared in this project can be renamed. If any file changes while myFunction computes the rename, it asks you to try again instead of applying a partial edit.
A related diagnostic catches the opposite problem. If two files both declare function readRequestTable_(), myFunction warns that the function is also declared in the other file and that only one definition is used at runtime.
Format a file, a selection, or every save
Right-click in the editor and choose Format Document to apply consistent indentation and spacing to the whole file. Select a few lines first to format only the selection. Formatting uses the editor's tab size and spaces setting.
To format each time you save, right-click and choose myFunction: Toggle Format on Save. A message confirms Format on save on. When you press Ctrl+S (Cmd+S on macOS), myFunction formats the focused file and then lets the save continue. If formatting takes more than two seconds, the save continues without waiting. The setting is off until you turn it on, and it is stored in this browser profile.
Extract and inline code with refactors
Select the filter callback in countOpenRequests, from function (row) through its closing brace. Open the code action menu with the lightbulb or Ctrl+.. Besides quick fixes, the menu offers refactors: extract the selection to a function or constant, inline a variable, convert to a template string, or convert between a function and an arrow function. You can also right-click and choose Refactor.... Each refactor rewrites code in the current project. It does not create files or add import and export statements, which Apps Script does not support.
Review the result before you save. A refactor keeps the code's behavior as far as the language service can tell, but you still need to choose a clear name for an extracted function.
The code action menu also offers performance fixes. Write a loop that calls sheet.getRange(row, 3).getValue() once per row, and myFunction warns that getValue() inside a loop reads one cell at a time. Read a rectangular range once with getValues() when the cells can be batched. This is the batching advice from the best-practices guide, the batching chapter, and the service call inside a loop guide, shown on the line that reads one cell at a time.
For one narrow loop shape, the menu also offers an automatic rewrite. When a counting loop reads range.getCell(row, 1).getValue() from a single-column range declared before the loop, the fix Read range once with getValues() before the loop inserts one getValues() call and replaces each cell read with an array lookup. Review the rewritten loop before applying the fix, and check whether batching is safe for that range. For other loops, such as the getRange(row, 3) example, rewrite the read yourself.
Use the command palette
Press Ctrl+Shift+P (Cmd+Shift+P on macOS) in the Apps Script editor, or click the Command palette button in the myFunction panel header, to open the myFunction command palette. Type to search the commands and the current problems together.

| Command | Shortcut | What it does |
|---|---|---|
| Go to next problem | Alt+Shift+J | Moves the cursor to the next problem. |
| Go to previous problem | Alt+Shift+K | Moves to the previous problem. |
| Show fixes for next problem | none | Moves to the next error or warning and opens its fixes. |
| Go to file... | Ctrl+P | Opens the quick-open picker to switch files. |
| Go to symbol in project... | none | Opens quick open with # to search functions, classes, and globals across the project. |
| Show myFunction panel | Alt+Shift+M | Opens the myFunction panel on the tab you used last. While the panel is open, the command reads Hide myFunction panel and closes it. |
| Show problems | none | Opens the Problems tab. |
| Show outline | none | Opens the Outline tab. |
| Hide Files sidebar | none | Hides the Apps Script Files column to give the code more room. While hidden, the command reads Show Files sidebar and restores it. |
| Toggle format on save | none | Turns format on save On or Off. |
| Switch inlay hints | none | Cycles inlay hints through Parameter names, Parameters & types, and Hidden. |
| Open account and billing | none | Opens Chrome's side panel for sign-in and billing. |
| Recheck project | none | Runs diagnostics again. |
| Open Apps Script field guide | none | Opens the myFunction field guide on myfunction.dev. |
On macOS, Ctrl is Cmd and Alt is Option. Scrolling past the commands reveals each current problem as an entry with its file and position. Choose one to jump there.
The editor's own command list opens with F1. myFunction also registers myFunction: Toggle Format on Save and the inlay hint commands described below in that list.
Open files and symbols by name
Press Ctrl+P (Cmd+P on macOS) to open the quick-open picker. Type part of a file name and press Enter to open that file.

Type # first to search declarations across the whole project: functions, classes, and variables. Each result shows the file that declares it.

In the sample project, type #Request to see the constant REQUESTS_SHEET and the functions that mention requests. The picker finds the declaration even when you remember only part of the name.
Navigate a file with the outline
The Outline tab of the myFunction panel lists the declarations in each file: top-level functions, classes, and global constants, plus the members of classes and of object literals used as namespaces. Click a row to move the cursor to that declaration. Type in Filter functions and globals (/) (or press / in the tab) to narrow the list.

The outline reads the file's structure without type-checking it, so it stays available while the file still has errors. For the sample project it lists the two constants and the four functions in Code.gs.
Read calls with inlay hints
A call such as getRange(2, 1, lastRow - 1, STATUS_COLUMN) is hard to read because the arguments have no labels. By default, myFunction shows parameter names as faint inline labels before literal arguments such as numbers and strings.

The labels make it easier to notice a swapped row and column, a mistake that passes type checking because both are numbers. To change the hints, press F1 and type inlay:

Show Parameter Names and Inferred Types also labels variables with their inferred types. It adds more text to the editor, so it is off by default. The choice is stored in this browser profile.
Exercise
Use the fixed sample project.
Add a second script file named
Report.gs. In it, writefunction countOpenRequests() {}. Read the warning that appears on both declarations, then delete the duplicate.In
Report.gs, write a function that loops from row 2 to the last row and callsgetRange(row, STATUS_COLUMN).getValue()on theRequestssheet for each row. Find the performance warning with Go to next problem. Rewrite the function to read the status column once withgetValues()and loop over the returned array, following the batching chapter's pattern. Confirm that the warning disappears.Use quick open with
#to jump toreadRequestTable_, the helper you renamed earlier, and rename it back toreadRequestRows_. Confirm with Shift+F12 that every call was updated.Hover over
getLastRowand follow the Apps Script reference link. Compare the documented return value with the declaration you see in Peek Definition.Turn on myFunction: Toggle Format on Save, indent one line incorrectly, and press Ctrl+S. Then turn the setting off again if you do not want to keep it.
When you finish, every file should show no problems in the Problems tab, and running countOpenRequests should log the same count as before. If the count changed, inspect your edits before you keep them. Delete the disposable spreadsheet when you no longer need it. To remove the extension, open chrome://extensions and click Remove on its card.
Next, read Debug executions and recover from limits.
Project files
Complete source files for this chapter's examples.
Fix a request counter with editor diagnostics
Code.gs
Download fileconst REQUESTS_SHEET = 'Requests';
const STATUS_COLUMN = 3;
/**
* Returns the bound spreadsheet's Requests sheet or stops with a clear error.
*
* @returns {SpreadsheetApp.Sheet}
*/
function getRequestsSheet_() {
const sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(REQUESTS_SHEET);
if (sheet === null) {
throw new Error('Add a sheet tab named ' + REQUESTS_SHEET + ' before running this function.');
}
return sheet;
}
/**
* Reads the request rows below the header. Returns an empty array when the
* sheet has only a header row.
*
* @param {SpreadsheetApp.Sheet} sheet
* @returns {unknown[][]}
*/
function readRequestRows_(sheet) {
const lastRow = sheet.getLastRow();
if (lastRow < 2) {
return [];
}
return sheet.getRange(2, 1, lastRow - 1, STATUS_COLUMN).getValues();
}
/**
* Logs the title of every request row.
*
* @returns {void}
*/
function logRequestTitles() {
const rows = readRequestRows_(getRequestsSheet_());
rows.forEach(function (row) {
Logger.log(row[1]);
});
}
/**
* Logs how many requests are not Done.
*
* This function contains four mistakes. Open it in the Apps Script editor
* with myFunction installed, then fix each one by reading the Problems panel.
*
* @returns {void}
*/
function countOpenRequests() {
const sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(REQUESTS_SHEET);
const lastRow = sheet.getLastRow();
const rows = sheet.getRange(2, 1, lastRow - 1, '3').getValues();
const open = rows.filter(function (row) {
return row[STATUS_COLUMN - 1] !== 'Done';
});
Logger.log('Open requests: ' + open.lenght);
}
appsscript.json
Download file{
"timeZone": "Etc/UTC",
"dependencies": {},
"exceptionLogging": "STACKDRIVER",
"runtimeVersion": "V8",
"oauthScopes": [
"https://www.googleapis.com/auth/spreadsheets.currentonly"
]
}