firebase / firebase-functions

Firebase SDK for Cloud Functions
https://firebase.google.com/docs/functions/
MIT License
1.01k stars 201 forks source link

Property 'child' in type 'DataSnapshot' is not assignable to the same property in base type 'DataSnapshot'. after updating `firebase-admin` to v12.0.0 #1513

Closed sceee closed 4 months ago

sceee commented 5 months ago

Related issues

Similar/the same issue as the closed issues #1442 and #1444 and https://github.com/firebase/firebase-functions/issues/1496#issuecomment-1876963016

I am just reopening this so it gets attention as the comments in the closed issues might be overlooked.

[REQUIRED] Version info

node: v18.18.0

firebase-functions: 4.6.0

firebase-tools: 13.0.3

firebase-admin: 12.0.0

[REQUIRED] Test case

Occurs during build.

[REQUIRED] Steps to reproduce

Build.

[REQUIRED] Expected behavior

No typescript compile error.

[REQUIRED] Actual behavior

node_modules/firebase-functions/lib/common/providers/database.d.ts:80:5 - error TS2416: Property 'child' in type 'DataSnapshot' is not assignable to the same property in base type 'DataSnapshot'.
  Type '(childPath: string) => DataSnapshot' is not assignable to type '(path: string) => DataSnapshot'.
    Call signature return types 'DataSnapshot' and 'DataSnapshot' are incompatible.
      The types of 'forEach' are incompatible between these types.
        Type '(action: (a: DataSnapshot) => boolean | void) => boolean' is not assignable to type '(action: (a: IteratedDataSnapshot) => boolean | void) => boolean'.
          Types of parameters 'action' and 'action' are incompatible.
            Types of parameters 'a' and 'a' are incompatible.
              Type 'DataSnapshot' is not assignable to type 'IteratedDataSnapshot'.
                Types of property 'key' are incompatible.
                  Type 'string | null' is not assignable to type 'string'.
                    Type 'null' is not assignable to type 'string'.

80     child(childPath: string): DataSnapshot;
       ~~~~~

node_modules/firebase-functions/lib/common/providers/database.d.ts:100:5 - error TS2416: Property 'forEach' in type 'DataSnapshot' is not assignable to the same property in base type 'DataSnapshot'.
  Type '(action: (a: DataSnapshot) => boolean | void) => boolean' is not assignable to type '(action: (a: IteratedDataSnapshot) => boolean | void) => boolean'.

100     forEach(action: (a: DataSnapshot) => boolean | void): boolean;

Were you able to successfully deploy your functions?

No, as they cannot be built.

google-oss-bot commented 5 months ago

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

Ax0elz commented 5 months ago

This seems like a regression that needs a hot fix ASAP. Can't use any of the aggregation since this forces you to downgrade the admin sdk version.

mariopepe commented 5 months ago

I am getting this error right now with:

  "dependencies": {
    "@faker-js/faker": "^8.4.0",
    "@types/google-libphonenumber": "^7.4.30",
    "@types/nodemailer": "^6.4.14",
    "axios": "^1.6.7",
    "firebase-admin": "^12.0.0",
    "firebase-functions": "^4.6.0",
    "fp-ts": "^2.16.2",
    "google-libphonenumber": "^3.2.34",
    "meilisearch": "^0.37.0",
    "nodemailer": "^6.9.8",
    "urlcat": "^3.1.0",
    "uuid": "^9.0.1"
  },

The error I get is:

npm run build

> build
> tsc

node_modules/firebase-functions/lib/common/providers/database.d.ts:80:5 - error TS2416: Property 'child' in type 'DataSnapshot' is not assignable to the same property in base type 'DataSnapshot'.
  Type '(childPath: string) => DataSnapshot' is not assignable to type '(path: string) => DataSnapshot'.
    Call signature return types 'DataSnapshot' and 'DataSnapshot' are incompatible.
      The types of 'forEach' are incompatible between these types.
        Type '(action: (a: DataSnapshot) => boolean | void) => boolean' is not assignable to type '(action: (a: IteratedDataSnapshot) => boolean | void) => boolean'.
          Types of parameters 'action' and 'action' are incompatible.
            Types of parameters 'a' and 'a' are incompatible.
              Type 'DataSnapshot' is not assignable to type 'IteratedDataSnapshot'.
                Types of property 'key' are incompatible.
                  Type 'string | null' is not assignable to type 'string'.
                    Type 'null' is not assignable to type 'string'.

80     child(childPath: string): DataSnapshot;
       ~~~~~

node_modules/firebase-functions/lib/common/providers/database.d.ts:100:5 - error TS2416: Property 'forEach' in type 'DataSnapshot' is not assignable to the same property in base type 'DataSnapshot'.
  Type '(action: (a: DataSnapshot) => boolean | void) => boolean' is not assignable to type '(action: (a: IteratedDataSnapshot) => boolean | void) => boolean'.

100     forEach(action: (a: DataSnapshot) => boolean | void): boolean;
        ~~~~~~~

Found 2 errors in the same file, starting at: node_modules/firebase-functions/lib/common/providers/database.d.ts:80
kmiterror commented 4 months ago

same error here firebase-admin 12.0.0 and firebase-function 4.6.0 are somewhat incompatible

exaby73 commented 4 months ago

This is fixed in https://github.com/firebase/firebase-functions/pull/1517. I will close this issue for the same reason