[TypeScript] The return type of drive.files.get
is inferred wrongly when downloading as media
#2052
Labels
priority: p2
Moderately-important priority. Fix may not be included in next release.
type: bug
Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
The following is a small snippet to download a file from Google Drive using this API.
The problem is that
drive.files.get
is defined to be returning (primarily)GaxiosPromise<Schema$File>
according to the type definitions around here. However, whenalt: "media"
is specified, the method returnsstring
(by default) orstream.PassThrough
(when{responseType: "stream"}
, or maybe other various types.Therefore, when I try to use the API with TypeScript properly, I have to apply an ugly cast (
as unknown as { data: stream.PassThrough }
to the response of the function. Can it be improved?The text was updated successfully, but these errors were encountered: