Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error TS1005: ';' expected on tsc #404

Closed
agordeev opened this issue Feb 3, 2019 · 48 comments
Closed

error TS1005: ';' expected on tsc #404

agordeev opened this issue Feb 3, 2019 · 48 comments

Comments

@agordeev
Copy link

agordeev commented Feb 3, 2019

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
}
@google-oss-bot
Copy link
Collaborator

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.

@merlinnot
Copy link
Contributor

Could you try to update TypeScript first?

@thechenky
Copy link
Contributor

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 thechenky added the Needs: Author Feedback Issues awaiting author feedback label Feb 3, 2019
@zbarbuto
Copy link

zbarbuto commented Feb 4, 2019

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

@agordeev
Copy link
Author

agordeev commented Feb 4, 2019

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

@agordeev agordeev closed this as completed Feb 4, 2019
@google-oss-bot google-oss-bot added Needs: Attention and removed Needs: Author Feedback Issues awaiting author feedback labels Feb 4, 2019
@thechenky
Copy link
Contributor

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

@nikhilbhalwankar
Copy link

I upgraded typescript to 3.3.1 which solved this issue.

@thechenky
Copy link
Contributor

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

@devpala
Copy link

devpala commented Mar 6, 2019

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

@GIOkafor
Copy link

GIOkafor commented May 2, 2019

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

@danieldanielecki
Copy link

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

@manel00
Copy link

manel00 commented Jul 24, 2019

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

@merlinnot
Copy link
Contributor

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: microsoft/TypeScript#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.

@manel00
Copy link

manel00 commented Jul 24, 2019

Sorry but it doesnt work still, i did it before

@merlinnot
Copy link
Contributor

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

@manel00
Copy link

manel00 commented Jul 25, 2019

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

@manel00
Copy link

manel00 commented Jul 25, 2019

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

@merlinnot
Copy link
Contributor

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

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

@Spiralis
Copy link

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.

@merlinnot
Copy link
Contributor

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.

@kkusanagi
Copy link

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"
},

@Spiralis
Copy link

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

@drsamdonegan
Copy link

@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"
},

@drsamdonegan
Copy link

@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"
},

@Spiralis
Copy link

Spiralis commented Sep 6, 2019

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

@merlinnot
Copy link
Contributor

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.

@Spiralis
Copy link

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.

@carlosefonseca
Copy link

carlosefonseca commented Sep 12, 2019

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 aws/aws-cdk#3839, fixed with npm install @types/node@8.

@mInzamamMalik

This comment was marked as abuse.

@mInzamamMalik

This comment was marked as abuse.

@valle-xyz
Copy link

Installing the latest version of typescript globally npm install -g typescript worked for me.
Also I updated the typescript version in functions/package.json.

@carlbonsu
Copy link

carlbonsu commented Apr 26, 2020

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)

@Birendrajha
Copy link

how to get rid of error TS 1005

@ghislainclaude
Copy link

how do you fix a ts(10005) error

@mnjit20
Copy link

mnjit20 commented Aug 19, 2020

installing updated version of typescript helped for me
npm install -g typescript

@ms-prasanth
Copy link

ms-prasanth commented Aug 21, 2020

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

npm install typescript --save-dev

It works. Thanks.

version occur in "devDependencies": "typescript": "^3.9.7"

@KR1470R
Copy link

KR1470R commented Sep 3, 2020

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???(((((

@danieldanielecki
Copy link

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???(((((

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.

@sebasas15
Copy link

I had the same problem but with @google-cloud/pubsub and just upgrading to "typescript": "^3.9.7" was the solution for me.

@Kgaugelo-Molema
Copy link

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

Thank you for the solution :-)

@Unsleeping
Copy link

"typescript": "4.9.3"
solved for me

@2sem
Copy link

2sem commented Sep 8, 2023

suddenly at 16.4.5...

"typescript": "4.2.4"

@Khufos
Copy link

Khufos commented Sep 11, 2023

Apaguei a pasta node_modules depois apaguei pasta onde estava os arquivos com esse error e depois instalei npm install typescript --save-dev , depois refiz os arquivos ai voltou ao normal , também é bom da um reload no vscode .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests