firebase-functions: error TS1005: ';' expected on tsc

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.

Related issues

[REQUIRED] Version info

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

[REQUIRED] Steps to reproduce

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
}

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 48 (9 by maintainers)

Commits related to this issue

Most upvoted comments

npm install typescript --save-dev did the trick. Thanks!

Could you try to update TypeScript first?

I upgraded typescript to 3.3.1 which solved this issue.

Can confirm bumping typescript to 3.1.3 fixed for me (was on 2.8.3)

Hi @agordeev thanks for filing - can you try @merlinnot 's suggestion and change your package.json typescript declataion to this:"typescript": "^3.1.3?

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](npm i --save-dev typescript@latest), which take this burden off your shoulders.

"typescript": "4.9.3" solved for me

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…


73 interface IteratorResult<T> { }
             ~~~~~~~~~~~~~~

  node_modules/typescript/lib/lib.es2015.iterable.d.ts:41:6
    41 type IteratorResult<T, TReturn = any> = IteratorYieldResult<T> | IteratorReturnResult<TReturn>;
            ~~~~~~~~~~~~~~
    'IteratorResult' was also declared here.

node_modules/typescript/lib/lib.es2015.iterable.d.ts:41:6 - error TS2300: Duplicate identifier 'IteratorResult'.

41 type IteratorResult<T, TReturn = any> = IteratorYieldResult<T> | IteratorReturnResult<TReturn>;
        ~~~~~~~~~~~~~~

  node_modules/@types/node/index.d.ts:73:11
    73 interface IteratorResult<T> { }
                 ~~~~~~~~~~~~~~
    '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.

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\Roaming\npm-cache_logs\2019-03-06T22_33_03_316Z-debug.log

Error: functions predeploy error: Command terminated with non-zero exit code2

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.

@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.

@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 had the same problem but with @google-cloud/pubsub and just upgrading to "typescript": "^3.9.7" was the solution for me.

This worked for me:

  1. npm install -g typescript (has to be installed globally so yes -g is needed)
  2. Restart Visual Studio (in my case I was using vscode)

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.

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 😃