Skip to content

Commit 041542f

Browse files
committed
Add changes to top-level index.d.ts
1 parent 078527a commit 041542f

File tree

2 files changed

+33
-18
lines changed

2 files changed

+33
-18
lines changed

packages/firebase/index.d.ts

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7617,6 +7617,22 @@ declare namespace firebase.storage {
76177617
md5Hash?: string | null;
76187618
}
76197619

7620+
/**
7621+
* An error returned by the Firebase Storage SDK.
7622+
*/
7623+
interface FirebaseStorageError {
7624+
name: string;
7625+
code: string;
7626+
message: string;
7627+
serverResponse: null | string;
7628+
}
7629+
7630+
interface StorageObserver<T> {
7631+
next?: NextFn<T> | null;
7632+
error?: (error: FirebaseStorageError) => void | null;
7633+
complete?: CompleteFn | null;
7634+
}
7635+
76207636
/**
76217637
* Represents the process of uploading an object. Allows you to monitor and
76227638
* manage the upload.
@@ -7630,7 +7646,7 @@ declare namespace firebase.storage {
76307646
/**
76317647
* Equivalent to calling `then(null, onRejected)`.
76327648
*/
7633-
catch(onRejected: (a: Error) => any): Promise<any>;
7649+
catch(onRejected: (error: FirebaseStorageError) => any): Promise<any>;
76347650
/**
76357651
* Listens for events on this task.
76367652
*
@@ -7730,7 +7746,7 @@ declare namespace firebase.storage {
77307746
* The `next` function, which gets called for each item in
77317747
* the event stream, or an observer object with some or all of these three
77327748
* properties (`next`, `error`, `complete`).
7733-
* @param error A function that gets called with an Error
7749+
* @param error A function that gets called with a `FirebaseStorageError`
77347750
* if the event stream ends due to an error.
77357751
* @param complete A function that gets called if the
77367752
* event stream ends normally.
@@ -7743,10 +7759,10 @@ declare namespace firebase.storage {
77437759
on(
77447760
event: firebase.storage.TaskEvent,
77457761
nextOrObserver?:
7746-
| Partial<firebase.Observer<UploadTaskSnapshot>>
7762+
| StorageObserver<UploadTaskSnapshot>
77477763
| null
7748-
| ((a: UploadTaskSnapshot) => any),
7749-
error?: ((a: Error) => any) | null,
7764+
| ((snapshot: UploadTaskSnapshot) => any),
7765+
error?: ((error: FirebaseStorageError) => any) | null,
77507766
complete?: firebase.Unsubscribe | null
77517767
): Function;
77527768
/**
@@ -7771,8 +7787,10 @@ declare namespace firebase.storage {
77717787
* @param onRejected The rejection callback.
77727788
*/
77737789
then(
7774-
onFulfilled?: ((a: firebase.storage.UploadTaskSnapshot) => any) | null,
7775-
onRejected?: ((a: Error) => any) | null
7790+
onFulfilled?:
7791+
| ((snapshot: firebase.storage.UploadTaskSnapshot) => any)
7792+
| null,
7793+
onRejected?: ((error: FirebaseStorageError) => any) | null
77767794
): Promise<any>;
77777795
}
77787796

packages/storage-types/index.d.ts

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
* limitations under the License.
1616
*/
1717

18-
import { FirebaseApp, FirebaseNamespace } from '@firebase/app-types';
18+
import { FirebaseApp } from '@firebase/app-types';
19+
import { CompleteFn, NextFn, Unsubscribe } from '@firebase/util';
1920

2021
export interface FullMetadata extends UploadMetadata {
2122
bucket: string;
@@ -91,34 +92,30 @@ export interface FirebaseStorageError {
9192
serverResponse: null | string;
9293
}
9394

94-
export type NextFn<T> = (value: T) => void;
95-
export type ErrorFn = (error: FirebaseStorageError) => void;
96-
export type CompleteFn = () => void;
97-
export type Unsubscribe = () => void;
9895
export interface StorageObserver<T> {
9996
next?: NextFn<T> | null;
100-
error?: ErrorFn | null;
97+
error?: (error: FirebaseStorageError) => void | null;
10198
complete?: CompleteFn | null;
10299
}
103100

104101
export interface UploadTask {
105102
cancel(): boolean;
106-
catch(onRejected: (a: FirebaseStorageError) => any): Promise<any>;
103+
catch(onRejected: (error: FirebaseStorageError) => any): Promise<any>;
107104
on(
108105
event: TaskEvent,
109106
nextOrObserver?:
110-
| Partial<StorageObserver<UploadTaskSnapshot>>
107+
| StorageObserver<UploadTaskSnapshot>
111108
| null
112-
| ((a: UploadTaskSnapshot) => unknown),
109+
| ((snapshot: UploadTaskSnapshot) => any),
113110
error?: ((a: FirebaseStorageError) => any) | null,
114111
complete?: Unsubscribe | null
115112
): Function;
116113
pause(): boolean;
117114
resume(): boolean;
118115
snapshot: UploadTaskSnapshot;
119116
then(
120-
onFulfilled?: ((a: UploadTaskSnapshot) => any) | null,
121-
onRejected?: ((a: FirebaseStorageError) => any) | null
117+
onFulfilled?: ((snapshot: UploadTaskSnapshot) => any) | null,
118+
onRejected?: ((error: FirebaseStorageError) => any) | null
122119
): Promise<any>;
123120
}
124121

0 commit comments

Comments
 (0)