Skip to content

Commit 215f172

Browse files
DellaBittatom-andersen
authored andcommitted
Fix FirebaseServerApp Typescript exactOptionalPropertyTypes error (#8341)
This change fixes a TypeScript compilation error. The `FirebaseServerAppSettings.name` field inherited from `FirebaseAppSettings` but the type was redefined from `string` to `undefined`. This redefinition would cause a TypeScript compliation error if `exactOptionalPropertyTypes` was set `true` in `packages/app/tsconfig.json`. This change now uses `omit< , >` to strip the `name` field from the `FirebaseServerAppSettings` declaration, where `FirebaseAppSettings` is extended. Fixes #8336
1 parent 42bfa94 commit 215f172

File tree

5 files changed

+18
-23
lines changed

5 files changed

+18
-23
lines changed

.changeset/silver-crews-build.md

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
'firebase': patch
3+
'@firebase/app': patch
4+
---
5+
6+
The `FirebaseServerAppSettings.name` field inherited from `FirebaseAppSettings` is now omitted
7+
instead of overloading the value as `undefined`. This fixes a TypeScript compilation error. For more
8+
information, see [GitHub Issue #8336](https://github.com/firebase/firebase-js-sdk/issues/8336).

common/api-review/app.api.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,8 @@ export interface FirebaseServerApp extends FirebaseApp {
7878
}
7979

8080
// @public
81-
export interface FirebaseServerAppSettings extends FirebaseAppSettings {
81+
export interface FirebaseServerAppSettings extends Omit<FirebaseAppSettings, 'name'> {
8282
authIdToken?: string;
83-
name?: undefined;
8483
releaseOnDeref?: object;
8584
}
8685

common/api-review/util.api.md

+5
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,11 @@ export const isValidFormat: (token: string) => boolean;
329329
// @public
330330
export const isValidTimestamp: (token: string) => boolean;
331331

332+
// Warning: (ae-missing-release-tag) "isWebWorker" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
333+
//
334+
// @public
335+
export function isWebWorker(): boolean;
336+
332337
// Warning: (ae-missing-release-tag) "jsonEval" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
333338
//
334339
// @public

docs-devsite/app.firebaseserverappsettings.md

+2-13
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,15 @@ Configuration options given to [initializeServerApp()](./app.md#initializeserver
1515
<b>Signature:</b>
1616

1717
```typescript
18-
export interface FirebaseServerAppSettings extends FirebaseAppSettings
18+
export interface FirebaseServerAppSettings extends Omit<FirebaseAppSettings, 'name'>
1919
```
20-
<b>Extends:</b> [FirebaseAppSettings](./app.firebaseappsettings.md#firebaseappsettings_interface)
20+
<b>Extends:</b> Omit&lt;[FirebaseAppSettings](./app.firebaseappsettings.md#firebaseappsettings_interface)<!-- -->, 'name'&gt;
2121
2222
## Properties
2323
2424
| Property | Type | Description |
2525
| --- | --- | --- |
2626
| [authIdToken](./app.firebaseserverappsettings.md#firebaseserverappsettingsauthidtoken) | string | An optional Auth ID token used to resume a signed in user session from a client runtime environment.<!-- -->Invoking <code>getAuth</code> with a <code>FirebaseServerApp</code> configured with a validated <code>authIdToken</code> causes an automatic attempt to sign in the user that the <code>authIdToken</code> represents. The token needs to have been recently minted for this operation to succeed.<!-- -->If the token fails local verification, or if the Auth service has failed to validate it when the Auth SDK is initialized, then a warning is logged to the console and the Auth SDK will not sign in a user on initialization.<!-- -->If a user is successfully signed in, then the Auth instance's <code>onAuthStateChanged</code> callback is invoked with the <code>User</code> object as per standard Auth flows. However, <code>User</code> objects created via an <code>authIdToken</code> do not have a refresh token. Attempted <code>refreshToken</code> operations fail. |
27-
| [name](./app.firebaseserverappsettings.md#firebaseserverappsettingsname) | undefined | There is no <code>getApp()</code> operation for <code>FirebaseServerApp</code>, so the name is not relevant for applications. However, it may be used internally, and is declared here so that <code>FirebaseServerApp</code> conforms to the <code>FirebaseApp</code> interface. |
2827
| [releaseOnDeref](./app.firebaseserverappsettings.md#firebaseserverappsettingsreleaseonderef) | object | An optional object. If provided, the Firebase SDK uses a <code>FinalizationRegistry</code> object to monitor the garbage collection status of the provided object. The Firebase SDK releases its reference on the <code>FirebaseServerApp</code> instance when the provided <code>releaseOnDeref</code> object is garbage collected.<!-- -->You can use this field to reduce memory management overhead for your application. If provided, an app running in a SSR pass does not need to perform <code>FirebaseServerApp</code> cleanup, so long as the reference object is deleted (by falling out of SSR scope, for instance.)<!-- -->If an object is not provided then the application must clean up the <code>FirebaseServerApp</code> instance by invoking <code>deleteApp</code>.<!-- -->If the application provides an object in this parameter, but the application is executed in a JavaScript engine that predates the support of <code>FinalizationRegistry</code> (introduced in node v14.6.0, for instance), then an error is thrown at <code>FirebaseServerApp</code> initialization. |
2928
3029
## FirebaseServerAppSettings.authIdToken
@@ -43,16 +42,6 @@ If a user is successfully signed in, then the Auth instance's `onAuthStateChange
4342
authIdToken?: string;
4443
```
4544
46-
## FirebaseServerAppSettings.name
47-
48-
There is no `getApp()` operation for `FirebaseServerApp`<!-- -->, so the name is not relevant for applications. However, it may be used internally, and is declared here so that `FirebaseServerApp` conforms to the `FirebaseApp` interface.
49-
50-
<b>Signature:</b>
51-
52-
```typescript
53-
name?: undefined;
54-
```
55-
5645
## FirebaseServerAppSettings.releaseOnDeref
5746
5847
An optional object. If provided, the Firebase SDK uses a `FinalizationRegistry` object to monitor the garbage collection status of the provided object. The Firebase SDK releases its reference on the `FirebaseServerApp` instance when the provided `releaseOnDeref` object is garbage collected.

packages/app/src/public-types.ts

+2-8
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,8 @@ export interface FirebaseAppSettings {
175175
*
176176
* Configuration options given to {@link (initializeServerApp:1) | initializeServerApp()}
177177
*/
178-
export interface FirebaseServerAppSettings extends FirebaseAppSettings {
178+
export interface FirebaseServerAppSettings
179+
extends Omit<FirebaseAppSettings, 'name'> {
179180
/**
180181
* An optional Auth ID token used to resume a signed in user session from a client
181182
* runtime environment.
@@ -215,13 +216,6 @@ export interface FirebaseServerAppSettings extends FirebaseAppSettings {
215216
* initialization.
216217
*/
217218
releaseOnDeref?: object;
218-
219-
/**
220-
* There is no `getApp()` operation for `FirebaseServerApp`, so the name is not relevant for
221-
* applications. However, it may be used internally, and is declared here so that
222-
* `FirebaseServerApp` conforms to the `FirebaseApp` interface.
223-
*/
224-
name?: undefined;
225219
}
226220

227221
/**

0 commit comments

Comments
 (0)