Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix FirebaseServerApp Typescript exactOptionalPropertyTypes error #8341

Merged
merged 11 commits into from
Jul 1, 2024
8 changes: 8 additions & 0 deletions .changeset/silver-crews-build.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
'firebase': patch
'@firebase/app': patch
---

The `FirebaseServerAppSettings.name` field inherited from `FirebaseAppSettings` is now omitted
instead of overloading the value as `undefined`. This fixes a TypeScript compilation error. For more
information, see [GitHub Issue #8336](https://github.com/firebase/firebase-js-sdk/issues/8336).
3 changes: 1 addition & 2 deletions common/api-review/app.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,8 @@ export interface FirebaseServerApp extends FirebaseApp {
}

// @public
export interface FirebaseServerAppSettings extends FirebaseAppSettings {
export interface FirebaseServerAppSettings extends Omit<FirebaseAppSettings, 'name'> {
authIdToken?: string;
name?: undefined;
releaseOnDeref?: object;
}

Expand Down
5 changes: 5 additions & 0 deletions common/api-review/util.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,11 @@ export const isValidFormat: (token: string) => boolean;
// @public
export const isValidTimestamp: (token: string) => boolean;

// Warning: (ae-missing-release-tag) "isWebWorker" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public
export function isWebWorker(): boolean;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apparently I missed the doc generate step on the user-created PR that added this function (#8315). My bad.

// Warning: (ae-missing-release-tag) "jsonEval" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public
Expand Down
15 changes: 2 additions & 13 deletions docs-devsite/app.firebaseserverappsettings.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,15 @@ Configuration options given to [initializeServerApp()](./app.md#initializeserver
<b>Signature:</b>

```typescript
export interface FirebaseServerAppSettings extends FirebaseAppSettings
export interface FirebaseServerAppSettings extends Omit<FirebaseAppSettings, 'name'>
```
<b>Extends:</b> [FirebaseAppSettings](./app.firebaseappsettings.md#firebaseappsettings_interface)
<b>Extends:</b> Omit&lt;[FirebaseAppSettings](./app.firebaseappsettings.md#firebaseappsettings_interface)<!-- -->, 'name'&gt;

## Properties

| Property | Type | Description |
| --- | --- | --- |
| [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. |
| [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. |
| [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. |

## FirebaseServerAppSettings.authIdToken
Expand All @@ -43,16 +42,6 @@ If a user is successfully signed in, then the Auth instance's `onAuthStateChange
authIdToken?: string;
```

## FirebaseServerAppSettings.name

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.

<b>Signature:</b>

```typescript
name?: undefined;
```

## FirebaseServerAppSettings.releaseOnDeref

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.
Expand Down
10 changes: 2 additions & 8 deletions packages/app/src/public-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,8 @@ export interface FirebaseAppSettings {
*
* Configuration options given to {@link (initializeServerApp:1) | initializeServerApp()}
*/
export interface FirebaseServerAppSettings extends FirebaseAppSettings {
export interface FirebaseServerAppSettings
extends Omit<FirebaseAppSettings, 'name'> {
/**
* An optional Auth ID token used to resume a signed in user session from a client
* runtime environment.
Expand Down Expand Up @@ -215,13 +216,6 @@ export interface FirebaseServerAppSettings extends FirebaseAppSettings {
* initialization.
*/
releaseOnDeref?: object;

/**
* 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.
*/
name?: undefined;
}

/**
Expand Down
Loading