Skip to content

Commit 5b84da7

Browse files
committed
Apply ErrorList type
1 parent 49041e2 commit 5b84da7

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

packages/app/src/errors.ts

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

18-
import { ErrorFactory } from '@firebase/util';
18+
import { ErrorFactory, ErrorList } from '@firebase/util';
1919

2020
export const enum AppError {
2121
NO_APP = 'no-app',
@@ -26,7 +26,7 @@ export const enum AppError {
2626
INVALID_APP_ARGUMENT = 'invalid-app-argument'
2727
}
2828

29-
const errors: { readonly [code in AppError]: string } = {
29+
const errors: ErrorList<AppError> = {
3030
[AppError.NO_APP]:
3131
"No Firebase App '{$name}' has been created - " +
3232
'call Firebase App.initializeApp()',
@@ -40,7 +40,7 @@ const errors: { readonly [code in AppError]: string } = {
4040
'Firebase App instance.'
4141
};
4242

43-
let appErrors = new ErrorFactory<AppError>('app', 'Firebase', errors);
43+
const appErrors = new ErrorFactory('app', 'Firebase', errors);
4444

4545
export function error(code: AppError, args?: { [name: string]: any }) {
4646
throw appErrors.create(code, args);

packages/messaging/src/models/errors.ts

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

18-
import { ErrorFactory } from '@firebase/util';
18+
import { ErrorFactory, ErrorList } from '@firebase/util';
1919

2020
export const enum ErrorCode {
2121
AVAILABLE_IN_WINDOW = 'only-available-in-window',
@@ -59,7 +59,7 @@ export const enum ErrorCode {
5959
PUBLIC_KEY_DECRYPTION_FAILED = 'public-vapid-key-decryption-failed'
6060
}
6161

62-
export const ERROR_MAP: { [code in ErrorCode]: string } = {
62+
export const ERROR_MAP: ErrorList<ErrorCode> = {
6363
[ErrorCode.AVAILABLE_IN_WINDOW]:
6464
'This method is available in a Window context.',
6565
[ErrorCode.AVAILABLE_IN_SW]:
@@ -156,7 +156,7 @@ export const ERROR_MAP: { [code in ErrorCode]: string } = {
156156
'The public VAPID key did not equal ' + '65 bytes when decrypted.'
157157
};
158158

159-
export const errorFactory: ErrorFactory<string> = new ErrorFactory(
159+
export const errorFactory = new ErrorFactory(
160160
'messaging',
161161
'Messaging',
162162
ERROR_MAP

packages/util/src/errors.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,9 @@
5454
* }
5555
* }
5656
*/
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
5960
};
6061

6162
const ERROR_NAME = 'FirebaseError';

0 commit comments

Comments
 (0)