Skip to content

Commit b124f73

Browse files
committed
Fix ErrorParams
1 parent f2bc2a2 commit b124f73

File tree

5 files changed

+19
-13
lines changed

5 files changed

+19
-13
lines changed

common/api-review/app-exp.api.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
```ts
66

77
import { Component } from '@firebase/component';
8-
import { FirebaseApp } from '@firebase/app-types';
9-
import { FirebaseAppConfig } from '@firebase/app-types';
10-
import { FirebaseOptions } from '@firebase/app-types';
8+
import { FirebaseApp } from '@firebase/app-types-exp';
9+
import { FirebaseAppConfig } from '@firebase/app-types-exp';
10+
import { FirebaseOptions } from '@firebase/app-types-exp';
1111
import { LogCallback } from '@firebase/logger';
1212
import { LogLevelString } from '@firebase/logger';
1313
import { LogOptions } from '@firebase/logger';

packages-exp/app-exp/src/api.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -284,10 +284,7 @@ export function onLog(
284284
options?: LogOptions
285285
): void {
286286
if (logCallback !== null && typeof logCallback !== 'function') {
287-
throw ERROR_FACTORY.create(AppError.INVALID_LOG_ARGUMENT, {
288-
// appName isn't used in INVALID_LOG_ARGUMENT error but ErrorFactory requires it
289-
appName: ''
290-
});
287+
throw ERROR_FACTORY.create(AppError.INVALID_LOG_ARGUMENT);
291288
}
292289
setUserLogHandler(logCallback, options);
293290
}

packages-exp/app-exp/src/errors.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,13 @@ const ERRORS: ErrorMap<AppError> = {
4040
'First argument to `onLog` must be null or a function.'
4141
};
4242

43-
type ErrorParams = { [key in AppError]: { appName: string } };
43+
interface ErrorParams {
44+
[AppError.NO_APP]: { appName: string };
45+
[AppError.BAD_APP_NAME]: { appName: string };
46+
[AppError.DUPLICATE_APP]: { appName: string };
47+
[AppError.APP_DELETED]: { appName: string };
48+
[AppError.INVALID_APP_ARGUMENT]: { appName: string };
49+
}
4450

4551
export const ERROR_FACTORY = new ErrorFactory<AppError, ErrorParams>(
4652
'app',

packages/app/src/errors.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,13 @@ const ERRORS: ErrorMap<AppError> = {
4040
'First argument to `onLog` must be null or a function.'
4141
};
4242

43-
type ErrorParams = { [key in AppError]: { appName: string } };
43+
interface ErrorParams {
44+
[AppError.NO_APP]: { appName: string };
45+
[AppError.BAD_APP_NAME]: { appName: string };
46+
[AppError.DUPLICATE_APP]: { appName: string };
47+
[AppError.APP_DELETED]: { appName: string };
48+
[AppError.INVALID_APP_ARGUMENT]: { appName: string };
49+
}
4450

4551
export const ERROR_FACTORY = new ErrorFactory<AppError, ErrorParams>(
4652
'app',

packages/app/src/firebaseNamespaceCore.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -287,10 +287,7 @@ export function createFirebaseNamespaceCore(
287287

288288
function onLog(logCallback: LogCallback | null, options?: LogOptions): void {
289289
if (logCallback !== null && typeof logCallback !== 'function') {
290-
throw ERROR_FACTORY.create(AppError.INVALID_LOG_ARGUMENT, {
291-
// appName isn't used in INVALID_LOG_ARGUMENT error but ErrorFactory requires it
292-
appName: ''
293-
});
290+
throw ERROR_FACTORY.create(AppError.INVALID_LOG_ARGUMENT);
294291
}
295292
setUserLogHandler(logCallback, options);
296293
}

0 commit comments

Comments
 (0)