File tree Expand file tree Collapse file tree 3 files changed +9
-8
lines changed Expand file tree Collapse file tree 3 files changed +9
-8
lines changed Original file line number Diff line number Diff line change 15
15
* limitations under the License.
16
16
*/
17
17
18
- import { ErrorFactory } from '@firebase/util' ;
18
+ import { ErrorFactory , ErrorList } from '@firebase/util' ;
19
19
20
20
export const enum AppError {
21
21
NO_APP = 'no-app' ,
@@ -26,7 +26,7 @@ export const enum AppError {
26
26
INVALID_APP_ARGUMENT = 'invalid-app-argument'
27
27
}
28
28
29
- const errors : { readonly [ code in AppError ] : string } = {
29
+ const errors : ErrorList < AppError > = {
30
30
[ AppError . NO_APP ] :
31
31
"No Firebase App '{$name}' has been created - " +
32
32
'call Firebase App.initializeApp()' ,
@@ -40,7 +40,7 @@ const errors: { readonly [code in AppError]: string } = {
40
40
'Firebase App instance.'
41
41
} ;
42
42
43
- let appErrors = new ErrorFactory < AppError > ( 'app' , 'Firebase' , errors ) ;
43
+ const appErrors = new ErrorFactory ( 'app' , 'Firebase' , errors ) ;
44
44
45
45
export function error ( code : AppError , args ?: { [ name : string ] : any } ) {
46
46
throw appErrors . create ( code , args ) ;
Original file line number Diff line number Diff line change 15
15
* limitations under the License.
16
16
*/
17
17
18
- import { ErrorFactory } from '@firebase/util' ;
18
+ import { ErrorFactory , ErrorList } from '@firebase/util' ;
19
19
20
20
export const enum ErrorCode {
21
21
AVAILABLE_IN_WINDOW = 'only-available-in-window' ,
@@ -59,7 +59,7 @@ export const enum ErrorCode {
59
59
PUBLIC_KEY_DECRYPTION_FAILED = 'public-vapid-key-decryption-failed'
60
60
}
61
61
62
- export const ERROR_MAP : { [ code in ErrorCode ] : string } = {
62
+ export const ERROR_MAP : ErrorList < ErrorCode > = {
63
63
[ ErrorCode . AVAILABLE_IN_WINDOW ] :
64
64
'This method is available in a Window context.' ,
65
65
[ ErrorCode . AVAILABLE_IN_SW ] :
@@ -156,7 +156,7 @@ export const ERROR_MAP: { [code in ErrorCode]: string } = {
156
156
'The public VAPID key did not equal ' + '65 bytes when decrypted.'
157
157
} ;
158
158
159
- export const errorFactory : ErrorFactory < string > = new ErrorFactory (
159
+ export const errorFactory = new ErrorFactory (
160
160
'messaging' ,
161
161
'Messaging' ,
162
162
ERROR_MAP
Original file line number Diff line number Diff line change 54
54
* }
55
55
* }
56
56
*/
57
- export type ErrorList < T extends string = string > = {
58
- readonly [ K in T ] : string
57
+
58
+ export type ErrorList < ErrorCode extends string > = {
59
+ readonly [ K in ErrorCode ] : string
59
60
} ;
60
61
61
62
const ERROR_NAME = 'FirebaseError' ;
You can’t perform that action at this time.
0 commit comments