firebase-functions icon indicating copy to clipboard operation
firebase-functions copied to clipboard

6.0.0 Property 'region' does not exist on type 'typeof import

Open davie-robertson opened this issue 1 year ago • 8 comments

Related issues

No - checked ChangeLog too

[REQUIRED] Version info

upgrade from ^5.1.1 to ^6.0.0

node:

v20.15.0

firebase-functions: ^6.0.0

firebase-tools:

13.17.0

firebase-admin:

[REQUIRED] Test case

all my cloud functions were setup to run in region region("europe-west1")

I did a firebase deploy --only functions and saw the prompt to npm install --save firebase-functions@latest

I then redeployed my cloud functions and got errors in two cloud functions stating that:

error TS2339: Property 'region' does not exist on type 'typeof import("/home/user/development/app/functions/node_modules/firebase-functions/lib/v2/index")'

[REQUIRED] Steps to reproduce

// This function will be triggered when a user is deleted
// It will delete the user document from the database and all relationships where the user is following others
import {UserRecord} from "firebase-admin/auth";
import {getFirestore} from "firebase-admin/firestore";
import * as functions from "firebase-functions";
import * as logger from "firebase-functions/logger";

export const deleteUserDocument = functions
  .region("europe-west1")
  .auth.user()
  .onDelete(async (user: UserRecord) => {
    const db = getFirestore();
    const userRef = db.collection("users").doc(user.uid);

    try {...}

[REQUIRED] Expected behavior

It should deploy in the same way as previously

[REQUIRED] Actual behavior

error on deployment

Were you able to successfully deploy your functions?

not since upgrading to 6.0.0

davie-robertson avatar Sep 15 '24 22:09 davie-robertson

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

google-oss-bot avatar Sep 15 '24 22:09 google-oss-bot

I just went through the recent code changes to the repo and saw that the default has changed.

So updating my imports to import * as functions from "firebase-functions/v1"; // Updated import fixed the issue.

Has this been documented anywhere?

Are we now able to use auth with v2 functions?

davie-robertson avatar Sep 15 '24 22:09 davie-robertson

where is the changelog mentioned in https://github.com/firebase/firebase-functions/pull/1606 This contains the breaking code warning

davie-robertson avatar Sep 17 '24 08:09 davie-robertson

import functions from 'firebase-functions' to --> import functions from 'firebase-functions/v1'

Did the trick for me.

sk8killer avatar Sep 18 '24 10:09 sk8killer

import functions from 'firebase-functions' to --> import functions from 'firebase-functions/v1'

Did the trick for me.

this should have been mentioned in the changelog

slk333 avatar Nov 09 '24 15:11 slk333

For others who land here from search, I had a similar error when trying to deploy cloud functions:

firebase cloud functions Property 'runWith' does not exist on type 'typeof...

The import from /v1 change described above helped, but I also had to downgrade firebase-functions to 5.0 from 6.0: yarn add firebase-functions@^5.0.1 The error occurred with version ^6.0 for me.

tomchify avatar Nov 16 '24 22:11 tomchify

@tomchify this seems like a separate issue - I can open a new issue to track this -

https://github.com/firebase/firebase-functions/issues/1654

feel free to add more details there if they'll help :)

cabljac avatar Dec 17 '24 14:12 cabljac

I will raise this with the team to see what we can do in terms of documenting this change properly

cabljac avatar Dec 17 '24 14:12 cabljac