googleapis / googleapis/google-api-nodejs-client
TypeScript error with official usage of sheets.values.batchUpdate
- Dominant language
- TypeScript
- Stars
- 12.2k
- Forks
- 2k
- Avg merge
- 1d 9h
- Merged PRs (30d)
- 24
Description
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
```ts
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!
Contributor guide
Assessment
This issue has not been assessed yet.