firebase-admin-node icon indicating copy to clipboard operation
firebase-admin-node copied to clipboard

TypeScript errors on Firebase Admin v12.0.0

Open petrvecera opened this issue 2 years ago • 3 comments

After update to firebase admin 12.0.0. we are unable to build any of our Firebase functions projects. We don't have problems on 11.11.1. As reported here on the forums https://github.com/firebase/firebase-admin-node/discussions/2411

The typescript errors come from inside the firebase libraries.

Env:

  • Node 20
  • Windows & Mac
  • TypeScript 5.3.3
../../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

Additional info for the deps in project:

 "dependencies": {
    "@google-cloud/storage": "7.7.0",
    "axios": "1.6.2",
    "axios-retry": "4.0.0",
    "cors": "2.8.5",
    "date-fns": "2.30.0",
    "express": "4.18.2",
    "express-validator": "7.0.1",
    "firebase-admin": "12.0.0",
    "firebase-functions": "4.6.0",
    "firestore-size": "2.0.7",
    "lodash": "4.17.21",
  },
  "devDependencies": {
    "@types/cors": "2.8.17",
    "@types/express": "4.17.21",
    "@types/jest": "29.5.11",
    "@types/lodash": "4.14.202",
    "@types/node": "20.11.10",
    "@typescript-eslint/eslint-plugin": "6.13.1",
    "@typescript-eslint/parser": "6.13.1",
    "eslint": "8.55.0",
    "eslint-config-google": "0.14.0",
    "eslint-plugin-import": "2.29.0",
    "firebase-functions-test": "3.1.0",
    "jest": "29.7.0",
    "ts-jest": "29.1.1",
    "typescript": "5.3.3"
  }

Workaround: In your tsconfig.json setup:

  "compilerOptions": {
    "skipLibCheck": true,
  },

petrvecera avatar Jan 30 '24 11:01 petrvecera

I found a few problems with this issue:

  • I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.
  • This issue does not seem to follow the issue template. Make sure you provide all the required information.

google-oss-bot avatar Jan 30 '24 11:01 google-oss-bot

any updates on this?

jibril101 avatar Feb 26 '24 21:02 jibril101

Any solution yet. This is affecting deployment

delebakare avatar Mar 18 '24 18:03 delebakare

This should be fixed in the latest release. If you are still facing this issue, we can reopen later.

lahirumaramba avatar May 21 '24 18:05 lahirumaramba