Skip to content

Node.js example for updating spreadsheet values does not compile #929

@songyang-dev

Description

@songyang-dev

Summary

Following the example on node.js, the Typescript compiler complains about incorrect types on the update method.

Expected Behavior

Sample URL: https://github.com/googleworkspace/node-samples/blob/main/sheets/snippets/sheets_update_values.js
Description: No Typescript errors

Actual Behavior

Screenshot 2024-10-24 at 7 50 18 PM
No overload matches this call.
  Overload 1 of 6, '(params?: Params$Resource$Spreadsheets$Values$Update | undefined, options?: MethodOptions | undefined): GaxiosPromise<...>', gave the following error.
    Object literal may only specify known properties, and 'resource' does not exist in type 'Params$Resource$Spreadsheets$Values$Update'.
  Overload 2 of 6, '(callback: BodyResponseCallback<Schema$UpdateValuesResponse>): void', gave the following error.
    Object literal may only specify known properties, and 'auth' does not exist in type 'BodyResponseCallback<Schema$UpdateValuesResponse>'.
  async setCells(range: string, values: string[][]) {
    return await this.sheets.spreadsheets.values.update({
      auth: this.auth,
      spreadsheetId: this.spreadsheetId,
      range: range,
      valueInputOption: "USER_ENTERED",
      resource: { values },
    });
  }

Steps to Reproduce the Problem

  1. Copy the API call for update from the docs into a project that has a JS server side, e.g. node.js or in my case, Nuxt.
  2. See the error.

Workaround

Changing resource to requestBody solves the issue. I suggest updating the docs.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions