You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The UploadTask callback type doesn't match what is documented here:
Callbacks can be passed either as three separate arguments or as the next, error, and complete properties of an object. Any of the three callbacks is optional, as long as at least one is specified. In addition, when you add your callbacks, you get a function back. You can call this function to unregister the associated callbacks.
But the UploadTask callback parameter type seems to require all three callbacks (i.e. it needs an object with next, complete, and error fields).
Relevant Code:
So I've called the UploadTaskon() method using an object containing the error and complete callbacks as follows:
ref.put(file).on(firebase.storage.TaskEvent.STATE_CHANGED,{asynccomplete(){onChange((awaitref.getDownloadURL()));setValue(`Uploaded ${filename}.`);},error(error: Error){setErrored(true);setValue(`An error occurred while uploading ${filename}. ${error.message}`);},});
But the UploadTask.prototype.on() type seems to require all three callbacks as I'm getting this Typescript error:
Argument of type '{ complete(): Promise<void>; error(error: Error): void; }' is not assignable to parameter of type 'Observer<UploadTaskSnapshot, Error> | ((a: UploadTaskSnapshot) => any) | null | undefined'.
Property 'next' is missing in type '{ complete(): Promise<void>; error(error: Error): void; }' but required in type 'Observer<UploadTaskSnapshot, Error>'.
And the relevant UploadTask.prototype.on() type is defined in node_modules/firebase/index.d.ts as follows:
Recommended fix
The fix here should be pretty easy. Just change the parameter in line 7582 of index.d.ts to be a Partial of firebase.Observer as follows:
This will make all of those callbacks optional. Though note that this is not a perfect solution, as your documentation specifies that at least one callback should be provided:
Any of the three callbacks is optional, as long as at least one is specified.
I'm sure that there's a way to do that with Typescript's built-in utility types though (I just don't want to try to figure it how right now because it's your job haha).
The text was updated successfully, but these errors were encountered:
[REQUIRED] Describe your environment
[REQUIRED] Describe the problem
Steps to reproduce:
The
UploadTask
callback type doesn't match what is documented here:But the
UploadTask
callback parameter type seems to require all three callbacks (i.e. it needs an object withnext
,complete
, anderror
fields).Relevant Code:
So I've called the
UploadTask
on()
method using an object containing theerror
andcomplete
callbacks as follows:But the
UploadTask.prototype.on()
type seems to require all three callbacks as I'm getting this Typescript error:And the relevant
UploadTask.prototype.on()
type is defined innode_modules/firebase/index.d.ts
as follows:Where a
firebase.Observer
is defined as:Recommended fix
The fix here should be pretty easy. Just change the parameter in line 7582 of
index.d.ts
to be aPartial
offirebase.Observer
as follows:This will make all of those callbacks optional. Though note that this is not a perfect solution, as your documentation specifies that at least one callback should be provided:
I'm sure that there's a way to do that with Typescript's built-in utility types though (I just don't want to try to figure it how right now because it's your job haha).
The text was updated successfully, but these errors were encountered: