Skip to content

TypeScript error with official usage of sheets.values.batchUpdate #3188

@rmehner

Description

@rmehner

Hey there,

I've ran into this non-critical, but a bit annoying issue with the API mentioned in the title. Would be nice if you could look into it!

Environment details

  • OS: macOS
  • Node.js version: 18.15.0
  • npm version: 9.5.0
  • googleapis version: 113.0.0

Steps to reproduce

const values = [1, 2, 3, 4, 5].map((number) => {
  return [number, number * 10]
})

const range = `Sheet!A2:B`
const data = [{ range, values }]
const valueInputOption = "USER_ENTERED"

const resource = {
  data,
  valueInputOption,
}

await sheets.spreadsheets.values.batchUpdate({ spreadsheetId: SPREADSHEET_ID, resource }) // <-- TS error here

This code works as expected (it fills in the the rows 2 to 6 and columns A & B with the right values. However, I do see a TS error for the call on batchUpdate that says No overload matches this call.. Digging into the code and the types, this looks correct, however the code just works, so I suspect it's a typing issue. Especially since the official examples are using the same code: https://github.com/googleworkspace/node-samples/blob/9f5d974bff57adf8135c1df11f8e110dc0ac01d4/sheets/snippets/sheets_batch_update_values.js#L39-L70

I suspect it works, because in the end everything is passed into Object.assign and Google understands the requests either way.

What do you think? Will this break in near future and if so, what am I supposed to use? Or is this a matter of fixing the types to also allow the option above?

Thanks in advance and have a great day!

Metadata

Metadata

Assignees

Labels

priority: p2Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions