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

error TS1005: ';' expected on tsc

Open agordeev opened this issue 7 years ago • 49 comments

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
}

agordeev avatar Feb 03 '19 16:02 agordeev

I found a few problems with this issue:

  • I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.
  • This issue does not seem to follow the issue template. Make sure you provide all the required information.

google-oss-bot avatar Feb 03 '19 16:02 google-oss-bot

Could you try to update TypeScript first?

merlinnot avatar Feb 03 '19 17:02 merlinnot

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

thechenky avatar Feb 03 '19 23:02 thechenky

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

zbarbuto avatar Feb 04 '19 04:02 zbarbuto

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

agordeev avatar Feb 04 '19 06:02 agordeev

Awesome, thanks everyone! Glad your issue was resolved @agordeev :)

thechenky avatar Feb 04 '19 07:02 thechenky

I upgraded typescript to 3.3.1 which solved this issue.

nikhilbhalwankar avatar Feb 06 '19 05:02 nikhilbhalwankar

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 :)

thechenky avatar Feb 08 '19 04:02 thechenky

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

devpala avatar Mar 06 '19 22:03 devpala

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

GIOkafor avatar May 02 '19 19:05 GIOkafor

When working on webpack changing "typescript": "~3.2.2" on "typescript": "^3.3.1" and hitting 'npm install' afterwards made the job.

danieldanielecki avatar Jul 18 '19 08:07 danieldanielecki

Sorry but there's no clear answer for me, can anyone put something to clearify it please?

manel00 avatar Jul 24 '19 09:07 manel00

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.

merlinnot avatar Jul 24 '19 10:07 merlinnot

Sorry but it doesnt work still, i did it before

manel00 avatar Jul 24 '19 12:07 manel00

Please provide a minimal repro so I can reproduce it and help. Otherwise it's impossible.

merlinnot avatar Jul 24 '19 16:07 merlinnot

Sorry i tried everything but doesnt work.... cannot put typescript last version, its incompatible with angular compiler

manel00 avatar Jul 25 '19 06:07 manel00

Please need help to fix it, its very annoying....

manel00 avatar Jul 25 '19 06:07 manel00

Angular requires TypeScript compiler from range 3.4, so that should be perfectly fine:

https://github.com/angular/angular/blob/c7542a1d09b27b027a0367a1f3732a908cdd617a/package.json#L111

merlinnot avatar Jul 25 '19 07:07 merlinnot

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.

danieldanielecki avatar Jul 25 '19 15:07 danieldanielecki

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 avatar Jul 28 '19 10:07 t4tapas