From 8e09a2120b2765fcf1fdba0b1cd76ab076462358 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Fri, 21 Nov 2025 22:37:18 +0000 Subject: [PATCH] fix(utils): resolve type errors and use template literals Resolves TypeScript errors in the 'utils' directory by: - Adding a placeholder function for `myFunction`. - Removing an unhelpful try/catch block. - Adding a JSDoc type annotation for a variable. - Correcting a call to `SpreadsheetApp.openById`. - Using template literals for string concatenation in `emailDataRow`. --- utils/logging.gs | 25 ++++++++++++++----------- utils/test_logging.gs | 3 ++- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/utils/logging.gs b/utils/logging.gs index cced7b3c4..b8959a931 100644 --- a/utils/logging.gs +++ b/utils/logging.gs @@ -15,6 +15,14 @@ */ // [START apps_script_logging_execution_time] +/** + * A placeholder function to be timed. + * @param {Object} parameters + */ +function myFunction(parameters) { + // Placeholder for the function being timed. +} + /** * Logs the time taken to execute 'myFunction'. */ @@ -50,16 +58,11 @@ function measuringExecutionTime() { * @param {string} email The email to send with the row data. */ function emailDataRow(rowNumber, email) { - console.log('Emailing data row ' + rowNumber + ' to ' + email); - try { - const sheet = SpreadsheetApp.getActiveSheet(); - const data = sheet.getDataRange().getValues(); - const rowData = data[rowNumber - 1].join(' '); - console.log('Row ' + rowNumber + ' data: ' + rowData); - MailApp.sendEmail(email, 'Data in row ' + rowNumber, rowData); - } catch (err) { - // TODO (developer) - Handle exception - console.log('Failed with error %s', err.message); - } + console.log(`Emailing data row ${rowNumber} to ${email}`); + const sheet = SpreadsheetApp.getActiveSheet(); + const data = sheet.getDataRange().getValues(); + const rowData = data[rowNumber - 1].join(' '); + console.log(`Row ${rowNumber} data: ${rowData}`); + MailApp.sendEmail(email, `Data in row ${rowNumber}`, rowData); } // [END apps_script_logging_sheet_information] diff --git a/utils/test_logging.gs b/utils/test_logging.gs index 4204bc181..723aeafbe 100644 --- a/utils/test_logging.gs +++ b/utils/test_logging.gs @@ -34,6 +34,7 @@ function populateValues(spreadsheetId) { const batchUpdateRequest = Sheets.newBatchUpdateSpreadsheetRequest(); const repeatCellRequest = Sheets.newRepeatCellRequest(); + /** @type {string[][]} */ const values = []; for (let i = 0; i < 10; ++i) { values[i] = []; @@ -54,7 +55,7 @@ function itShouldEmailDataRow() { const email = Session.getActiveUser().getEmail(); const spreadsheetId = createTestSpreadsheet(); populateValues(spreadsheetId); - const data = Spreadsheet.openById(); + const data = SpreadsheetApp.openById(spreadsheetId); emailDataRow(1, email); }