Skip to content

Commit 7476d35

Browse files
committed
Used interface instead of class
1 parent 5585cdf commit 7476d35

File tree

2 files changed

+48
-2
lines changed

2 files changed

+48
-2
lines changed

packages/storage-compat/src/task.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ export class UploadTaskCompat implements types.UploadTask, Compat<UploadTask> {
6565
| types.StorageObserver<UploadTaskSnapshotCompat>
6666
| null
6767
| ((a: UploadTaskSnapshotCompat) => unknown),
68-
error?: (error: StorageError) => void | null,
68+
error?: ((error: StorageError) => void) | null,
6969
completed?: () => void | null
7070
): Unsubscribe | Subscribe<UploadTaskSnapshotCompat> {
7171
let wrappedNextOrObserver:

packages/storage-types/index.d.ts

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616
*/
1717

1818
import { FirebaseApp } from '@firebase/app-types';
19-
import { StorageError as FirebaseStorageError } from '@firebase/storage';
2019
import {
2120
CompleteFn,
2221
EmulatorMockTokenOptions,
22+
FirebaseError,
2323
NextFn,
2424
Unsubscribe
2525
} from '@firebase/util';
@@ -96,7 +96,53 @@ export interface StorageObserver<T> {
9696
error?: (error: FirebaseStorageError) => void | null;
9797
complete?: CompleteFn | null;
9898
}
99+
export declare enum StorageErrorCode {
100+
UNKNOWN = 'unknown',
101+
OBJECT_NOT_FOUND = 'object-not-found',
102+
BUCKET_NOT_FOUND = 'bucket-not-found',
103+
PROJECT_NOT_FOUND = 'project-not-found',
104+
QUOTA_EXCEEDED = 'quota-exceeded',
105+
UNAUTHENTICATED = 'unauthenticated',
106+
UNAUTHORIZED = 'unauthorized',
107+
UNAUTHORIZED_APP = 'unauthorized-app',
108+
RETRY_LIMIT_EXCEEDED = 'retry-limit-exceeded',
109+
INVALID_CHECKSUM = 'invalid-checksum',
110+
CANCELED = 'canceled',
111+
INVALID_EVENT_NAME = 'invalid-event-name',
112+
INVALID_URL = 'invalid-url',
113+
INVALID_DEFAULT_BUCKET = 'invalid-default-bucket',
114+
NO_DEFAULT_BUCKET = 'no-default-bucket',
115+
CANNOT_SLICE_BLOB = 'cannot-slice-blob',
116+
SERVER_FILE_WRONG_SIZE = 'server-file-wrong-size',
117+
NO_DOWNLOAD_URL = 'no-download-url',
118+
INVALID_ARGUMENT = 'invalid-argument',
119+
INVALID_ARGUMENT_COUNT = 'invalid-argument-count',
120+
APP_DELETED = 'app-deleted',
121+
INVALID_ROOT_OPERATION = 'invalid-root-operation',
122+
INVALID_FORMAT = 'invalid-format',
123+
INTERNAL_ERROR = 'internal-error',
124+
UNSUPPORTED_ENVIRONMENT = 'unsupported-environment'
125+
}
126+
export interface FirebaseStorageError extends FirebaseError {
127+
/**
128+
* Stores custom error data unque to StorageError.
129+
*/
130+
customData: {
131+
serverResponse: string | null;
132+
};
99133

134+
get status(): number;
135+
set status(status: number);
136+
/**
137+
* Compares a StorageErrorCode against this error's code, filtering out the prefix.
138+
*/
139+
_codeEquals(code: StorageErrorCode): boolean;
140+
/**
141+
* Optional response message that was added by the server.
142+
*/
143+
get serverResponse(): null | string;
144+
set serverResponse(serverResponse: string | null);
145+
}
100146
export interface UploadTask {
101147
cancel(): boolean;
102148
catch(onRejected: (error: FirebaseStorageError) => any): Promise<any>;

0 commit comments

Comments
 (0)