Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

node_modules/firebase-functions/lib/function-configuration.d.ts:4:64 - error TS1005: ']' expected

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"
like image 236
Tapas Mukherjee Avatar asked Jul 28 '19 16:07

Tapas Mukherjee


3 Answers

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

like image 131
Pal Avatar answered Nov 16 '22 00:11

Pal


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.

like image 44
zhirzh Avatar answered Nov 16 '22 02:11

zhirzh


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.

like image 33
jai angular Avatar answered Nov 16 '22 01:11

jai angular