googleapis / nodejs-common

πŸš€πŸ’ A set of classes and utilities used in Google npm modules.
Apache License 2.0
58 stars 35 forks source link

[NPM ERROR] Interface 'ServiceOptions' incorrectly extends interface #734

Closed zubairzahoor closed 2 years ago

zubairzahoor commented 2 years ago

Since today, I am unable to build my project with this error. Nothing changed from our side,

Types of property 'authClient' are incompatible. 11:08:51 Type 'GoogleAuth | undefined' is not assignable to type 'JSONClient | undefined'. 11:08:51 node_modules/@google-cloud/common/build/src/util.d.ts(42,18): error TS2430: Interface 'MakeAuthenticatedRequestFactoryConfig' incorrectly extends interface 'GoogleAuthOptions'. 11:08:51 Types of property 'authClient' are incompatible. 11:08:51 Type 'GoogleAuth | undefined' is not assignable to type 'JSONClient | undefined'. 11:08:51 Type 'GoogleAuth' is not assignable to type 'JSONClient | undefined'. 11:08:51 Type 'GoogleAuth' is missing the following properties from type 'JWT': createScoped, getRequestMetadataAsync, fetchIdToken, hasUserScopes

Environment details

Steps to reproduce

A simple npm run build causes this.

robin-whg commented 2 years ago

Having the same issue with the package in firebase cloud functions.

zubairzahoor commented 2 years ago

This is most likely an issue with google-auth-library that was updated yesterday. Issue here: https://github.com/googleapis/google-auth-library-nodejs/issues/1374

finallyRaunak commented 2 years ago

This is most likely an issue with google-auth-library that was updated yesterday. Issue here: googleapis/google-auth-library-nodejs#1374

Yes, I also think the same, having the same issue with @google-cloud/logging-winston package which uses google-auth-library

SametSahin10 commented 2 years ago

I'm having the same issue.

bcoe commented 2 years ago

πŸ‘‹ for folks having issues, could you provide the output of npm ls google-auth-library, a new version of the auth library was released yesterday, but the current latest version of the library remained 7.12.0. So, I'm not sure how npm would be pulling in 7.14.0.

bcoe commented 2 years ago

@SametSahin10 @zubairzahoor follow up question, what @google-cloud library are you using?

SametSahin10 commented 2 years ago

wave for folks having issues, could you provide the output of npm ls google-auth-library, a new version of the auth library was released yesterday, but the current latest version of the library remained 7.12.0. So, I'm not sure how npm would be pulling in 7.14.0.

Output of npm ls google-auth-library:

functions@ /home/sametsahin/work/firebase-projects/flambu/functions └─┬ firebase-admin@10.0.2 β”œβ”€β”¬ @google-cloud/firestore@4.15.1 β”‚ └─┬ google-gax@2.30.0 β”‚ └── google-auth-library@7.14.0 deduped └─┬ @google-cloud/storage@5.18.2 β”œβ”€β”¬ @google-cloud/common@3.9.0 β”‚ └── google-auth-library@7.14.0 deduped └── google-auth-library@7.14.0

SametSahin10 commented 2 years ago

@SametSahin10 @zubairzahoor follow up question, what @google-cloud library are you using?

Does my last comment answer this as well?

bcoe commented 2 years ago

@SametSahin10 @zubairzahoor if you remove your package-lock.json and reinstall, you should stop seeing a build error.

I'm keeping this open until the problem is fixed, for now I just rolled back google-gax, which is the dependency forcing 7.14.0 of the auth library.

danielbankhead commented 2 years ago

Hey everyone! Apologies for the broken builds; the type-related issues should now be resolved via (nodejs-common v3.10.0) https://github.com/googleapis/nodejs-common/pull/733.

bcoe commented 2 years ago

@danielbankhead I think because of the collision on the key-name authClient we should call the update to GoogleAuth breaking, or else folks could end up with trees that can't compile.

What do you think?

edit: perhaps as long as all the dependencies are functioning together, we're in okay shape, let's just monitor this closely throughout the day.

danielbankhead commented 2 years ago

[Synced offline, sharing here for visibility]

I think we should be fine, nodejs-common is the only library in googleapis with the name collision (others use the conventional auth param) - and is the only library with issues with the updated auth library.

https://github.com/googleapis/nodejs-common/pull/733 should resolve this, however I'll keep this open and monitor over the next few days.

finallyRaunak commented 2 years ago

πŸ‘‹ for folks having issues, could you provide the output of npm ls google-auth-library, a new version of the auth library was released yesterday, but the current latest version of the library remained 7.12.0. So, I'm not sure how npm would be pulling in 7.14.0.

@bcoe : Here is the output

β”œβ”€β”¬ @google-cloud/logging-winston@4.1.2 β”‚ └── google-auth-library@7.14.0 β”œβ”€β”¬ @google-cloud/logging@9.7.0 β”‚ β”œβ”€β”¬ @google-cloud/common@3.9.0 β”‚ β”‚ └── google-auth-library@7.14.0 deduped β”‚ β”œβ”€β”€ google-auth-library@7.14.0 deduped β”‚ └─┬ google-gax@2.30.0 β”‚ └── google-auth-library@7.14.0 deduped └─┬ @google-cloud/storage@5.18.2 └── google-auth-library@7.14.0 deduped

ederius100 commented 2 years ago

Hi guys, me output β”‚ └─┬ @. β”‚ β”œβ”€β”¬ @@. β”‚ β”‚ └─┬ @. β”‚ β”‚ └── @. deduped β”‚ └─┬ @@. β”‚ β”œβ”€β”¬ @@. β”‚ β”‚ └── @. β”‚ └── @. deduped └─┬ @. β”œβ”€β”¬ @@. β”‚ β”œβ”€β”€ @. β”‚ └─┬ @. β”‚ └── @. deduped └── @.

Looks like when google-auth-library is a dependency of @. is installing @. Good luck!

On Wed, Feb 23, 2022 at 4:10 PM Daniel Bankhead @.***> wrote:

[Synced offline, sharing here for visibility]

I think we should be fine, nodejs-common is the only library in googleapis https://github.com/googleapis with the name collision (others use the conventional auth param) - and is the only library with issues with the updated auth library.

733 https://github.com/googleapis/nodejs-common/pull/733 should

resolve this, however I'll keep this open and monitor over the next few days.

β€” Reply to this email directly, view it on GitHub https://github.com/googleapis/nodejs-common/issues/734#issuecomment-1049218940, or unsubscribe https://github.com/notifications/unsubscribe-auth/ATVDB6KB5DGT7Y3XDBKPCELU4VEL3ANCNFSM5PDMVTGA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you are subscribed to this thread.Message ID: @.***>

bcoe commented 2 years ago

@finallyRaunak a clean install (make sure have @google-cloud/common@3.10.0) should address the problem you were seeing.

For anyone else bumping into issues, use npm ls to list deps, and ensure your tree has the latest patch.

danielbankhead commented 2 years ago

Things are looking stable as of @google-cloud/common@3.10.0 - closing. https://github.com/googleapis/nodejs-common/pull/733.

appfrilans commented 2 years ago

I still have a similar issue.

node_modules/@google-cloud/common/build/src/service.d.ts:29:18 - error TS2430: Interface 'ServiceOptions' incorrectly extends interface 'GoogleAuthOptions<JSONClient>'.
  Types of property 'authClient' are incompatible.
    Type 'GoogleAuth<JSONClient> | undefined' is not assignable to type 'JWT | UserRefreshClient | Impersonated | BaseExternalAccountClient | undefined'.
      Type 'GoogleAuth<JSONClient>' is not assignable to type 'JWT | UserRefreshClient | Impersonated | BaseExternalAccountClient | undefined'.
        Type 'GoogleAuth<JSONClient>' is not assignable to type 'JWT'.

29 export interface ServiceOptions extends GoogleAuthOptions {
                    ~~~~~~~~~~~~~~

node_modules/@google-cloud/common/build/src/util.d.ts:42:18 - error TS2430: Interface 'MakeAuthenticatedRequestFactoryConfig' incorrectly extends interface 'GoogleAuthOptions<JSONClient>'.
  Types of property 'authClient' are incompatible.
    Type 'GoogleAuth<JSONClient> | undefined' is not assignable to type 'JWT | UserRefreshClient | Impersonated | BaseExternalAccountClient | undefined'.
      Type 'GoogleAuth<JSONClient>' is not assignable to type 'JWT | UserRefreshClient | Impersonated | BaseExternalAccountClient | undefined'.
        Type 'GoogleAuth<JSONClient>' is missing the following properties from type 'JWT': createScoped, getRequestMetadataAsync, fetchIdToken, hasUserScopes, and 53 more.

42 export interface MakeAuthenticatedRequestFactoryConfig extends GoogleAuthOptions {
                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Using Firebase Functions with typeScript. Using the following imports:

import * as functions from "firebase-functions";
import * as admin from "firebase-admin";
import * as geofire from "geofire-common";
import * as key from './service-account-key.json';
import { google } from 'googleapis';

Running Β΄npm ls google-auth-libraryΒ΄ gives me: └── (empty)

Tried updating all npm's to latest version. My package.json looks like this:

{
  "name": "functions",
  "scripts": {
    "lint": "eslint --ext .js,.ts .",
    "build": "tsc",
    "serve": "npm run build && firebase emulators:start --only functions",
    "shell": "npm run build && firebase functions:shell",
    "start": "npm run shell",
    "deploy": "firebase deploy --only functions",
    "logs": "firebase functions:log"
  },
  "engines": {
    "node": "16"
  },
  "main": "lib/index.js",
  "dependencies": {
    "@google-cloud/logging": "^9.8.0",
    "date-fns": "^2.28.0",
    "dateformat": "^5.0.2",
    "firebase": "^9.6.8",
    "firebase-admin": "^9.8.0",
    "firebase-functions": "^3.18.1",
    "geofire-common": "^5.2.0",
    "googleapis": "^96.0.0",
    "request": "^2.88.2"
  },
  "devDependencies": {
    "@typescript-eslint/eslint-plugin": "^3.9.1",
    "@typescript-eslint/parser": "^3.8.0",
    "eslint": "^7.6.0",
    "eslint-config-google": "^0.14.0",
    "eslint-plugin-import": "^2.22.0",
    "eslint-plugin-promise": "^6.0.0",
    "firebase-functions-test": "^0.2.0",
    "typescript": "^3.8.0"
  },
  "private": true
}

Adding "skipLibCheck": true to my tsconfig.json solves the issue but seems like a workaround.

bcoe commented 2 years ago

@appfrilans could I bother you to rm package-lock.json, and to reinstall. My guess is you're still on an older version of the auth library.

appfrilans commented 2 years ago

Solved it by manually installing @google-cloud/common@3.10.0 with npm install --save @google-cloud/logging

bcoe commented 2 years ago

@appfrilans great, sorry for the slow response I'm glad you're unblocked πŸ‘

b2m9 commented 2 years ago

For people who arrive here wondering why they can't deploy new Firebase Cloud Functions anymore:

It seems to me that firebase-admin@10.0.2 requires @google-cloud/storage@5.3.0 which requires @google-cloud/common@3.6.0.

For everyone looking to resolve that without using skipLibCheck:true, run npm install @google-cloud/common@3.10.0 and you should be able to deploy your Cloud Functions again.