I'me getting the following error when trying to run npm run build:
node_modules/firebase-functions/lib/function-builder.d.ts(60,95): error TS1005: ';' expected.
node_modules/firebase-functions/lib/function-builder.d.ts(60,96): error TS1003: Identifier expected.
node_modules/firebase-functions/lib/function-builder.d.ts(60,116): error TS1005: ';' expected.
node_modules/gaxios/build/src/index.d.ts(14,66): error TS1005: '>' expected.
node_modules/gaxios/build/src/index.d.ts(14,103): error TS1109: Expression expected.
node:
v8.12.0
firebase-functions:
2.2.0 (same error with 2.1.0)
firebase-tools:
6.3.1
firebase-admin:
7.0.0
Create an empty firebase TypeScript project and try to compile.
Here's my package.json:
{
"name": "functions",
"scripts": {
"lint": "tslint --project tsconfig.json",
"build": "tsc",
"serve": "npm run build && firebase serve --only functions",
"shell": "npm run build && firebase functions:shell",
"start": "npm run shell",
"deploy": "firebase deploy --only functions",
"logs": "firebase functions:log"
},
"main": "lib/index.js",
"dependencies": {
"firebase-admin": "^7.0.0",
"firebase-functions": "^2.2.0"
},
"devDependencies": {
"tslint": "~5.8.0",
"typescript": "~2.8.3"
},
"private": true
}
I found a few problems with this issue:
Could you try to update TypeScript first?
Hi @agordeev thanks for filing - can you try @merlinnot 's suggestion and change your package.json typescript declataion to this:"typescript": "^3.1.3?
Can confirm bumping typescript to 3.1.3 fixed for me (was on 2.8.3)
npm install typescript --save-dev did the trick. Thanks!
Awesome, thanks everyone! Glad your issue was resolved @agordeev :)
I upgraded typescript to 3.3.1 which solved this issue.
Seeing as caused issues for a few people, we have now added the mention of TypeScript update into the release notes for v2.2.0. Thanks again everyone :)
node_modules/firebase-functions/lib/function-builder.d.ts(60,116): error TS1005: ';' expected.
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! functions@ build: tsc
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the functions@ build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Ruben Palavecino\AppData\Roamingnpm-cache_logs\2019-03-06T22_33_03_316Z-debug.log
Error: functions predeploy error: Command terminated with non-zero exit code2
@RUPALAVECINO did you try updating to firebase-admin@^7.0.0?
I ran npm install typescript --save-dev but still got errors which running: npm install firebase-admin@^7.0.0 made go away.
It could be that package(firebase-admin), or another peer dependency preventing it from installing.
When working on webpack changing "typescript": "~3.2.2" on "typescript": "^3.3.1" and hitting 'npm install' afterwards made the job.
Sorry but there's no clear answer for me, can anyone put something to clearify it please?
Sure. This library uses syntax introduced in TypeScript 3.4, which allows us to provide better experience to our users by having better autocompletion and stricter compiler (static) checks, so your code breaks less in runtime.
The specific syntax that causes the issue for you is const assertion (as const), introduced in TypeScript 3.4: https://github.com/Microsoft/TypeScript/pull/29435
You need to update your TypeScript compiler to at least this version, by running e.g. npm i --save-dev typescript@latest.
As a side note, I can recommend automatic your dependency update process by using tools like Renovate, which take this burden off your shoulders.
Sorry but it doesnt work still, i did it before
Please provide a minimal repro so I can reproduce it and help. Otherwise it's impossible.
Sorry i tried everything but doesnt work.... cannot put typescript last version, its incompatible with angular compiler
Please need help to fix it, its very annoying....
Angular requires TypeScript compiler from range 3.4, so that should be perfectly fine:
https://github.com/angular/angular/blob/c7542a1d09b27b027a0367a1f3732a908cdd617a/package.json#L111
Hi @manel00,
The newer TypeScript versions (above 3.3) don't work with Angular's 7 compiler (at least 7.2.15). What means that for upgrading to TypeScript 3.4 you need to have your project in Angular 8 most probably, i.e. there is no compatibility with previous versions for the compilation. I can confirm you that it does works, I upgraded Angular to 8.1.1 and have the following Firebase dependencies:
"firebase": "^6.3.1",
"firebase-admin": "^8.2.0",
"firebase-functions": "^3.0.2",
TypeScrpt version: 3.4.2.
I still have the issue with the following versions.
"firebase": "^6.3.1",
"firebase-admin": "^8.2.0",
"firebase-functions": "3.2.0",
"angularfire2": "^5.2.1"
@t4tapas do you have TypeScript > 3.4 and Angular 8?
@danieldanielecki "typescript": "^3.5.3" and this project is in ionic 3 using angularfire2
Not working for me neither
"dependencies": {
"firebase-admin": "^8.3.0",
"firebase-functions": "^3.2.0"
},
"devDependencies": {
"@types/express": "^4.17.1",
"tslint": "^5.18.0",
"typescript": "^3.5.3"
},
Upgraded all global libraries too. Tried with both node 10.16.0 and 8.16.1
Cloned the sample typescript project.
Is there a "special magic combo" of versions that is known to work?
Errors:
> tsc.cmd
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"];
~
Found 6 errors.
If you use tsc from a command line, it uses your global installation. Try running it through npx: https://blog.npmjs.org/post/162869356040/introducing-npx-an-npm-package-runner.
i use back old version thats work.
here.
"dependencies": {
"express": "^4.17.1",
"firebase-admin": "^7.4.0",
"firebase-functions": "^2.3.1",
"firebase-tools": "^7.2.4"
},
"devDependencies": {
"tslint": "~5.8.0",
"typescript": "^3.5.3"
},
@merlinnot I have made sure to upgrade the global tsc too, and also made sure that I was using the global one. Not working. I forced using the local tsc too. None of the approaches worked.
@kkusanagi I will try those versions asap, thanks:
@Spiralis I've found a combination of the most updated versions that appears to work for me:
"dependencies": {
"firebase-admin": "^8.5.0",
"firebase-functions": "^3.0.2"
},
"devDependencies": {
"tslint": "~5.8.0",
"typescript": "^3.3.1"
},
@Spiralis These are the most updated versions that appear to work:
"dependencies": {
"firebase-admin": "^8.5.0",
"firebase-functions": "^3.0.2"
},
"devDependencies": {
"tslint": "~5.8.0",
"typescript": "^3.3.1"
},
I tried to produce a minimal case to reproduce and it all worked. However, as I moved the functions folder into the same project as my netxjs/react/firestore typescript application (using yarn), the compilation failed.
At the moment I am instead keeping the firebase functions in a separate project. It might be mix of npm and yarn, it might be something different. I don't have the time to investigate more, as I have to do some actual coding too :)
If anyone is able to provide a reproduction, I'll gladly fix it. But it seems to me that it's just a matter of TypeScript version.
Well. I am not sure anymore. I have had different errors. But, it seems to me that I am not able to set this up as a sub-folder in my main firebase repo. That is, where I host my typescript nextjs firebase project, using yarn. I can set it up as a separate folder and repo it seems, but within that repo, no go. So, I have made a separate repo for it now.
I think I have the latest ts, tslint, firebase-admin,firebase-functions and it doesn't work…
{
"engines": {
"node": "8"
},
"name": "functions",
"scripts": {
"lint": "tslint --project tsconfig.json",
"build": "rm -rf lib && tsc",
"serve": "npm run build && firebase serve --only functions",
"shell": "npm run build && firebase experimental:functions:shell",
"start": "npm run shell",
"deploy": "firebase deploy --only functions",
"logs": "firebase functions:log"
},
"main": "lib/index.js",
"dependencies": {
"@types/request-promise": "^4.1.41",
"camelcase": "^5.0.0",
"firebase-admin": "8.5.0",
"firebase-functions": "^3.2.0",
"glob": "^7.1.2",
"moment": "^2.22.1",
"request": "^2.80.0",
"request-promise": "^4.1.1"
},
"devDependencies": {
"tslint": "^5.20.0",
"typescript": "^3.6.3"
},
"private": true
}
and I get this…
```node_modules/@types/node/index.d.ts:73:11 - error TS2300: Duplicate identifier 'IteratorResult'.
73 interface IteratorResult
~~~~~~
node_modules/typescript/lib/lib.es2015.iterable.d.ts:41:6
41 type IteratorResult
~~~~~~
'IteratorResult' was also declared here.
node_modules/typescript/lib/lib.es2015.iterable.d.ts:41:6 - error TS2300: Duplicate identifier 'IteratorResult'.
41 type IteratorResult
~~~~~~
node_modules/@types/node/index.d.ts:73:11
73 interface IteratorResult
~~~~~~
'IteratorResult' was also declared here.
Found 2 errors.
also…
❯ tsc --version
Version 3.6.3
```
EDIT:
Sorry, just found this https://github.com/aws/aws-cdk/issues/3839, fixed with npm install @types/node@8.
@carlosefonseca @Spiralis @OldCarrots @kkusanagi @agordeev @google-oss-bot @merlinnot @thechenky @zbarbuto
In my case I just removed stub type from my packege.json and it started working for me
"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
please vote up https://stackoverflow.com/a/59941420/4378475
Installing the latest version of typescript globally npm install -g typescript worked for me.
Also I updated the typescript version in functions/package.json.
This worked for me:
how to get rid of error TS 1005
how do you fix a ts(10005) error
installing updated version of typescript helped for me
npm install -g typescript
npm install typescript --save-devdid the trick. Thanks!
npm install typescript --save-dev
It works. Thanks.
version occur in "devDependencies": "typescript": "^3.9.7"
I tried:
sudo npm install -g typescript
sudo npm install typescript --save-dev
But it's not work.
"dependencies": {
"@google-cloud/translate": "^6.0.2",
"@types/npm": "^2.0.31",
"cheerio": "^1.0.0-rc.3",
"request": "^2.88.2"
},
"devDependencies": {
"typescript": "^4.0.2"
}
How i can fix that???(((((
I tried:
sudo npm install -g typescript sudo npm install typescript --save-devBut it's not work.
"dependencies": { "@google-cloud/translate": "^6.0.2", "@types/npm": "^2.0.31", "cheerio": "^1.0.0-rc.3", "request": "^2.88.2" }, "devDependencies": { "typescript": "^4.0.2" }How i can fix that???(((((
Similarly to @ms-prasanth I'm on "typescript": "^3.9.7" and it works. Simply try to install this version of TypeScript, I can see that you're on TypeScript 4 already.
Most helpful comment
npm install typescript --save-devdid the trick. Thanks!