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

Compilation Error with Typescript when enabling "exactOptionalPropertyTypes" #8336

Closed
ansf opened this issue Jun 26, 2024 · 3 comments · Fixed by #8341
Closed

Compilation Error with Typescript when enabling "exactOptionalPropertyTypes" #8336

ansf opened this issue Jun 26, 2024 · 3 comments · Fixed by #8341
Assignees

Comments

@ansf
Copy link

ansf commented Jun 26, 2024

Operating System

macOS 14

Browser Version

Chrome 126

Firebase SDK Version

10.12.2

Firebase SDK Product:

Analytics

Describe your project's tooling

typescript project, with "exactOptionalPropertyTypes" enabled in tsconfig.json.

Describe the problem

The project does not compile and gives the following error:

node_modules/@firebase/app/dist/app-public.d.ts:201:26 - error TS2430: Interface 'FirebaseServerAppSettings' incorrectly extends interface 'FirebaseAppSettings'.
  Types of property 'name' are incompatible.
    Type 'undefined' is not assignable to type 'string'.

201 export declare interface FirebaseServerAppSettings extends FirebaseAppSettings {

With exactOptionalPropertyTypes the both declarations of name are not compatible (see https://www.typescriptlang.org/tsconfig/#exactOptionalPropertyTypes).

This is actually a duplicate of #8227, but I was unable to comment on the original issue and wanted to provide a minimal reproducible example (see below)

Steps and code to reproduce issue

  1. Checkout https://github.com/ansf/firebase-8227-mre
  2. npm i
  3. npm run compile
@ansf ansf added new A new issue that hasn't be categoirzed as question, bug or feature request question labels Jun 26, 2024
@google-oss-bot
Copy link
Contributor

I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.

@jbalidiong jbalidiong added api: core needs-attention and removed needs-triage new A new issue that hasn't be categoirzed as question, bug or feature request labels Jun 26, 2024
@jbalidiong
Copy link
Contributor

Hi @ansf, thanks for reaching out to us. I was able to reproduce the error using your code. I'll communicate this with our engineers and bring someone here that can provide more context about it. I’ll update this thread if I have any information to share.

@DellaBitta
Copy link
Contributor

This fix should go out in our next release!

tom-andersen pushed a commit that referenced this issue Jul 24, 2024
)

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
@firebase firebase locked and limited conversation to collaborators Aug 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants