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

new firebase init functions TypeScript fails on serve or build with errors #4212

Closed
tamakunay opened this issue Feb 23, 2022 · 6 comments
Closed
Assignees

Comments

@tamakunay
Copy link

[REQUIRED] Environment info

**firebase-tools: 10.2.1

**Platform: macOS

[REQUIRED] Test case

Using current latest firebase-tools, a freshly-created TypeScript functions project fails to run or deploy

[REQUIRED] Steps to reproduce

mkdir test-project

cd test-project

firebase init functions

cd functions

npm run serve / deploy

[REQUIRED] Expected behavior

The project should run and deploy

[REQUIRED] Actual behavior

fails with:

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

42 export interface MakeAuthenticatedRequestFactoryConfig extends GoogleAuthOptions {

same error even with debug flag

@tamakunay tamakunay added the bug label Feb 23, 2022
@tamakunay
Copy link
Author

not sure why but if I add
"skipLibCheck": true, in tsconfig file its ok but if not then won't work
based on this
#749

@digibake
Copy link

Thanks @tamakunay,

Adding "skipLibCheck": true inside compilerOptions (tsconfig.json) has solved the issue for me too, as a temporary solution.

@taeold
Copy link
Contributor

taeold commented Feb 23, 2022

hmm this looks similar to #4181, but from a different package.

Root issuse: googleapis/nodejs-common#734

@taeold taeold self-assigned this Feb 23, 2022
@taeold
Copy link
Contributor

taeold commented Feb 23, 2022

It looks like @google-cloud/common v3.10.0 (released today) should fix this. A clean install would probably make the error go away.

Let us know if anyone is still having troubles.

@tamakunay
Copy link
Author

tamakunay commented Feb 24, 2022

@taeold a clean install works fine now without the need to add "skipLibCheck": true
thanks for the update

It looks like @google-cloud/common v3.10.0 (released today) should fix this. A clean install would probably make the error go away.

Let us know if anyone is still having troubles.

@taeold taeold closed this as completed Feb 24, 2022
@appfrilans
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants