Skip to content

Commit 8520470

Browse files
fix(picker): resolve type errors (#586)
Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com> Co-authored-by: Justin Poehnelt <jpoehnelt@google.com>
1 parent a903bd5 commit 8520470

File tree

2 files changed

+25
-3
lines changed

2 files changed

+25
-3
lines changed

picker/code.gs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,18 @@ function showPicker() {
3636
.setSandboxMode(HtmlService.SandboxMode.IFRAME);
3737
SpreadsheetApp.getUi().showModalDialog(html, "Select a file");
3838
}
39+
// Ensure the Drive API is enabled.
40+
if (!Drive) {
41+
throw new Error('Please enable the Drive advanced service.');
42+
}
43+
3944
/**
4045
* Checks that the file can be accessed.
46+
* @param {string} fileId The ID of the file.
47+
* @return {Object} The file resource.
4148
*/
4249
function getFile(fileId) {
43-
return Drive.Files.get(fileId, { fields: "*" });
50+
return Drive.Files.get(fileId, {fields: '*'});
4451
}
4552

4653
/**

picker/dialog.html

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,12 +109,27 @@
109109
}
110110
}
111111

112+
/**
113+
* @typedef {Object} PickerResponse
114+
* @property {string} action
115+
* @property {PickerDocument[]} docs
116+
*/
117+
118+
/**
119+
* @typedef {Object} PickerDocument
120+
* @property {string} id
121+
* @property {string} name
122+
* @property {string} mimeType
123+
* @property {string} url
124+
* @property {string} lastEditedUtc
125+
*/
126+
112127
/**
113128
* A callback function that extracts the chosen document's metadata from the
114129
* response object. For details on the response object, see
115130
* https://developers.google.com/picker/reference/picker.responseobject
116131
*
117-
* @param {object} data The response object.
132+
* @param {PickerResponse} data The response object.
118133
*/
119134
function pickerCallback(data) {
120135
const action = data[google.picker.Response.ACTION];
@@ -128,7 +143,7 @@
128143
/**
129144
* Handles `"PICKED"` responsed from the Google Picker.
130145
*
131-
* @param {object} data The response object.
146+
* @param {PickerResponse} data The response object.
132147
*/
133148
function handlePicked(data) {
134149
const doc = data[google.picker.Response.DOCUMENTS][0];

0 commit comments

Comments
 (0)