Wrong typing for gapi.client responses
ph-fritsche opened this issue · 2 comments
Typing
The headers property of client method responses gapi.client.Response['headers']
are typed as headers?: any[]
Actual type
The client method responses have a property of type headers: {[headerName: string]: string}
Additional info
gapi.client.drive.FilesResource[method]
(and others) are typed as gapi.client.Request<T>
which extends Promise<gapi.client.Response<T>>
.
E.g. (await gapi.client.drive.files.get(params)).headers
returns an object of header values while it is typed as an iterable.
Hello, thank you for flagging this!
I can confirm that this is the case in Google Drive, and in Google Sheets.
So, I assume that it affects all APIs and will update @types/gapi.client
package.
These types can't be generated, unfortunately. Because there's no schema.
In order to provide the best typings for the gapi client - we need to research minified sources of gapi.
I've started working on this research here: https://github.com/Maxim-Mazurok/gapi
Please, feel free to contribute in any way, it would be much appreciated!
The fix was merged and published.
Please, give @types/gapi.client@1.0.4 a try :)