Skip to content

Commit c9a2e25

Browse files
fix(ui): resolve type errors
- Corrects a typo in `ui/communication/failure/code.gs`. - Adds JSDoc annotations to `ui/communication/private/code.gs`, `ui/communication/runner.gs`, and `ui/forms/code.gs` to resolve type errors. - Adds trailing newlines to `ui/communication/failure/code.gs` and `ui/communication/private/code.gs`.
1 parent 275a497 commit c9a2e25

4 files changed

Lines changed: 69 additions & 5 deletions

File tree

ui/communication/failure/code.gs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ function doGet() {
44

55
function getUnreadEmails() {
66
// 'got' instead of 'get' will throw an error.
7-
return GmailApp.gotInboxUnreadCount();
8-
}
7+
return GmailApp.getInboxUnreadCount();
8+
}

ui/communication/private/code.gs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,12 @@ function getBankBalance() {
77
return deepSecret_(email);
88
}
99

10+
/**
11+
* @param {string} email The user's email address.
12+
* @return {string} A string with the user's balance.
13+
* @private
14+
*/
1015
function deepSecret_(email) {
11-
// Do some secret calculations
12-
return email + ' has $1,000,000 in the bank.';
13-
}
16+
// Do some secret calculations
17+
return email + ' has $1,000,000 in the bank.';
18+
}

ui/communication/runner.gs

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,52 @@
1+
/* eslint-disable no-unused-vars */
2+
3+
/**
4+
* @typedef {Object} GoogleScriptRun
5+
* @property {function():void} doSomething
6+
* @property {function():void} doSomethingElse
7+
* @property {function(function(string):void):GoogleScriptRun} withSuccessHandler
8+
* @property {function(function(Error):void):GoogleScriptRun} withFailureHandler
9+
*/
10+
11+
/**
12+
* @type {{script: {run: GoogleScriptRun}}}
13+
*/
14+
var google = {
15+
script: {
16+
run: {
17+
doSomething: function() {},
18+
doSomethingElse: function() {},
19+
withSuccessHandler: function() {
20+
return this;
21+
},
22+
withFailureHandler: function() {
23+
return this;
24+
},
25+
},
26+
},
27+
};
28+
29+
/**
30+
* @param {Error} error
31+
*/
32+
function onFailure(error) {
33+
console.log(error.message);
34+
}
35+
36+
/**
37+
* @param {string} result
38+
*/
39+
function onSuccess(result) {
40+
console.log(result);
41+
}
42+
43+
/**
44+
* @param {string} result
45+
*/
46+
function onDifferentSuccess(result) {
47+
console.log(result);
48+
}
49+
150
var myRunner = google.script.run.withFailureHandler(onFailure);
251
var myRunner1 = myRunner.withSuccessHandler(onSuccess);
352
var myRunner2 = myRunner.withSuccessHandler(onDifferentSuccess);

ui/forms/code.gs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@ function doGet() {
22
return HtmlService.createHtmlOutputFromFile('Index');
33
}
44

5+
/**
6+
* @typedef {{myFile: any}} FormObject
7+
*/
8+
9+
/**
10+
* Processes a form submission with a file upload.
11+
*
12+
* @param {FormObject} formObject The form object submitted by the user.
13+
* @return {string} The URL of the uploaded file.
14+
*/
515
function processForm(formObject) {
616
var formBlob = formObject.myFile;
717
var driveFile = DriveApp.createFile(formBlob);

0 commit comments

Comments
 (0)