From f01806221bcf1edb4356c5901ee65ba322851981 Mon Sep 17 00:00:00 2001 From: DellaBitta Date: Mon, 1 Jul 2024 18:09:06 -0400 Subject: [PATCH] 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 --- .changeset/silver-crews-build.md | 8 ++++++++ common/api-review/app.api.md | 3 +-- common/api-review/util.api.md | 5 +++++ docs-devsite/app.firebaseserverappsettings.md | 15 ++------------- packages/app/src/public-types.ts | 10 ++-------- 5 files changed, 18 insertions(+), 23 deletions(-) create mode 100644 .changeset/silver-crews-build.md diff --git a/.changeset/silver-crews-build.md b/.changeset/silver-crews-build.md new file mode 100644 index 00000000000..e9cf0d08eae --- /dev/null +++ b/.changeset/silver-crews-build.md @@ -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). diff --git a/common/api-review/app.api.md b/common/api-review/app.api.md index e226940ef1b..bdfb2a681f1 100644 --- a/common/api-review/app.api.md +++ b/common/api-review/app.api.md @@ -78,9 +78,8 @@ export interface FirebaseServerApp extends FirebaseApp { } // @public -export interface FirebaseServerAppSettings extends FirebaseAppSettings { +export interface FirebaseServerAppSettings extends Omit { authIdToken?: string; - name?: undefined; releaseOnDeref?: object; } diff --git a/common/api-review/util.api.md b/common/api-review/util.api.md index 75e484edd50..09558e72ce8 100644 --- a/common/api-review/util.api.md +++ b/common/api-review/util.api.md @@ -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; + // Warning: (ae-missing-release-tag) "jsonEval" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public diff --git a/docs-devsite/app.firebaseserverappsettings.md b/docs-devsite/app.firebaseserverappsettings.md index 59aba9bca78..bc46c5292d0 100644 --- a/docs-devsite/app.firebaseserverappsettings.md +++ b/docs-devsite/app.firebaseserverappsettings.md @@ -15,16 +15,15 @@ Configuration options given to [initializeServerApp()](./app.md#initializeserver Signature: ```typescript -export interface FirebaseServerAppSettings extends FirebaseAppSettings +export interface FirebaseServerAppSettings extends Omit ``` -Extends: [FirebaseAppSettings](./app.firebaseappsettings.md#firebaseappsettings_interface) +Extends: Omit<[FirebaseAppSettings](./app.firebaseappsettings.md#firebaseappsettings_interface), 'name'> ## 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 getAuth with a FirebaseServerApp configured with a validated authIdToken causes an automatic attempt to sign in the user that the authIdToken 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 onAuthStateChanged callback is invoked with the User object as per standard Auth flows. However, User objects created via an authIdToken do not have a refresh token. Attempted refreshToken operations fail. | -| [name](./app.firebaseserverappsettings.md#firebaseserverappsettingsname) | undefined | 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. | | [releaseOnDeref](./app.firebaseserverappsettings.md#firebaseserverappsettingsreleaseonderef) | object | 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.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 FirebaseServerApp 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 FirebaseServerApp instance by invoking deleteApp.If the application provides an object in this parameter, but the application is executed in a JavaScript engine that predates the support of FinalizationRegistry (introduced in node v14.6.0, for instance), then an error is thrown at FirebaseServerApp initialization. | ## FirebaseServerAppSettings.authIdToken @@ -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. - -Signature: - -```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. diff --git a/packages/app/src/public-types.ts b/packages/app/src/public-types.ts index eb963a54adf..ff25de93a46 100644 --- a/packages/app/src/public-types.ts +++ b/packages/app/src/public-types.ts @@ -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 { /** * An optional Auth ID token used to resume a signed in user session from a client * runtime environment. @@ -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; } /**