Skip to content

Commit 949c6ac

Browse files
authored
Syntax fixes in 'app' packages (#4409)
1 parent 318af54 commit 949c6ac

File tree

9 files changed

+25
-15
lines changed

9 files changed

+25
-15
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-compat/src/firebaseApp.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ export class FirebaseAppImpl implements FirebaseApp {
6868
}
6969

7070
delete(): Promise<void> {
71-
return new Promise(resolve => {
71+
return new Promise<void>(resolve => {
7272
this.app.checkDestroyed();
7373
resolve();
7474
}).then(() => {

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -284,9 +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: name
289-
});
287+
throw ERROR_FACTORY.create(AppError.INVALID_LOG_ARGUMENT);
290288
}
291289
setUserLogHandler(logCallback, options);
292290
}

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/firebaseApp.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ export class FirebaseAppImpl implements FirebaseApp {
8686
}
8787

8888
delete(): Promise<void> {
89-
return new Promise(resolve => {
89+
return new Promise<void>(resolve => {
9090
this.checkDestroyed_();
9191
resolve();
9292
})

packages/app/src/firebaseNamespaceCore.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -287,9 +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: name
292-
});
290+
throw ERROR_FACTORY.create(AppError.INVALID_LOG_ARGUMENT);
293291
}
294292
setUserLogHandler(logCallback, options);
295293
}

packages/app/src/lite/firebaseAppLite.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ export class FirebaseAppLiteImpl implements FirebaseApp {
9090
}
9191

9292
delete(): Promise<void> {
93-
return new Promise(resolve => {
93+
return new Promise<void>(resolve => {
9494
this.checkDestroyed_();
9595
resolve();
9696
})

packages/app/src/lite/firebaseNamespaceLite.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,9 @@ export function createFirebaseNamespaceLite(): FirebaseNamespace {
4848
component.name !== 'performance' &&
4949
component.name !== 'installations'
5050
) {
51-
throw Error(`${name} cannot register with the standalone perf instance`);
51+
throw Error(
52+
`${component.name} cannot register with the standalone perf instance`
53+
);
5254
}
5355

5456
return registerComponent(component);

0 commit comments

Comments
 (0)