9

I am getting the following error when executing the command firebase deploy --only function in my Ionic 3 project. This solution is not working for me.

Running command: npm --prefix "$RESOURCE_DIR" run build
> functions@ build /Users/myuser/Project/functions
> tsc

node_modules/firebase-functions/lib/function-configuration.d.ts:4:64 - error TS1005: ']' expected.
4 export declare const SUPPORTED_REGIONS: readonly ["us-central1", "us-east1", "us-east4", "europe-west1", "europe-west2", "asia-east2", "asia-northeast1"];
                                                                             ~

node_modules/firebase-functions/lib/function-configuration.d.ts:4:66 - error TS1134: Variable declaration expected.
4 export declare const SUPPORTED_REGIONS: readonly ["us-central1", "us-east1", "us-east4", "europe-west1", "europe-west2", "asia-east2", "asia-northeast1"];
                                                                   ~~~~~~~~~~

node_modules/firebase-functions/lib/function-configuration.d.ts:4:153 - error TS1005: ';' expected.
4 export declare const SUPPORTED_REGIONS: readonly ["us-central1", "us-east1", "us-east4", "europe-west1", "europe-west2", "asia-east2", "asia-northeast1"];
                                                                                                                                                          ~

node_modules/firebase-functions/lib/function-configuration.d.ts:16:61 - error TS1005: ']' expected.
16 export declare const VALID_MEMORY_OPTIONS: readonly ["128MB", "256MB", "512MB", "1GB", "2GB"];
                                                               ~

node_modules/firebase-functions/lib/function-configuration.d.ts:16:63 - error TS1134: Variable declaration expected.
16 export declare const VALID_MEMORY_OPTIONS: readonly ["128MB", "256MB", "512MB", "1GB", "2GB"];
                                                                 ~~~~~~~

node_modules/firebase-functions/lib/function-configuration.d.ts:16:93 - error TS1005: ';' expected.
16 export declare const VALID_MEMORY_OPTIONS: readonly ["128MB", "256MB", "512MB", "1GB", "2GB"];
                                                                                               ~

When I look into file node_modules/firebase-functions/lib/function-configuration.d.ts, it shows the syntax errors.


Version details:

"angularfire2": "^5.2.1",
"firebase": "^6.3.1",
"firebase-admin": "^8.2.0",
"firebase-functions": "3.2.0",
"typescript": "^3.5.3"

4 Answers 4

6

npm install -g [email protected] worked for me. I assume higher versions would work as well. It is important to update the global typescript version as my local typescript version update didn't work

Sign up to request clarification or add additional context in comments.

3 Comments

Still the same error after npm install -g [email protected]. As I mentioned my version "typescript": "^3.5.3"
What I really meant was a version upgrade as mine got fixed by upgrading 3.3.x -->3.5.x that fixed the exact same error. Have you used the "-g" flag? Additionally upgrade your npm firebase-tools and firebase-functions packages
Yes, I used-g flag. I have also tried installing firebase-tools. Could you please let me know how to upgrade or reinstall firebase-function package.
1

Judging from the github issue that you linked and the error message itself, the error seems to be due to the new readonly tuples feature. It was introduced in [email protected] so, in theory, any typescript version higher than that should work.

In fact, [email protected] uses [email protected] so I recommend you use the same or higher.


That being said, I see that you have already used [email protected] but the error still popped up.

Version details:

"angularfire2": "^5.2.1",
"firebase": "^6.3.1",
"firebase-admin": "^8.2.0",
"firebase-functions": "3.2.0",
"typescript": "^3.5.3"

It may be because of a different (older) typescript version being used by some other package internally. Please check your package-lock.json (or yarn.lock) to confirm.

If that's not the case, then my next best guess is that ionic-app-scripts is using older typescript internally.

Comments

1

Check if any space got added into starting of this file. I had the same issue and after removing the space in the top of the file it was working.

Comments

-1

In my case I just removed stub type from my packege.json and it started working for me updating just everything was not working, because this old shit is not compatable with the newer version of firebase well you didnt mentioned in your question that you do have this in your dependencies but I am 100% sure the problem is coming from here, because I just spent a whole night because of this:

"dependencies": {
   "@types/firebase": "^3.2.1",  <<====== this is shit man
   "@types/fs-extra": "^8.0.1",
   "@types/mongoose": "^5.5.43",
   "@types/request": "^2.48.4",
   "actions-on-google": "^2.12.0",
   "bcrypt-inzi": "^1.0.7",
   "body-parser": "^1.18.3",
   "dialogflow-fulfillment": "^0.6.1",
   "express": "^4.17.1",
   "firebase-admin": "^8.6.0",
   "firebase-functions": "^3.3.0",
   "fs-extra": "^8.1.0",
   "mongoose": "^5.8.9",
   "request": "^2.88.0"
 },

have you noticed this warning when running npm i

npm WARN deprecated @types/[email protected]: This is a stub types definition for Firebase API (https://www.firebase.com/docs/javascript/firebase). Firebase API provides its own type definitions, so you don't need @types/firebase installed!

since firebase functions have its own typing file it is not required at all now

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.