TypeScript error TS1005: ';' expected (II)

后端 未结 9 1023
旧巷少年郎
旧巷少年郎 2020-12-09 02:11

First of all, I\'ve already seen the other posts about error TS1005. Same error code, but totally different.

A simple let x: number; will gener

相关标签:
9条回答
  • 2020-12-09 02:28
    • Remove C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.0 directory.

    • Now run :

      npm install -g typescript 
      

      this will install the latest version and then re-try.

    0 讨论(0)
  • 2020-12-09 02:36

    Just try to without changing anything npm install rxjs@X.X.X X.X.X is your current version

    0 讨论(0)
  • 2020-12-09 02:37

    Your installation is wrong; you are using a very old compiler version (1.0.3.0).

    tsc --version should return a version of 2.5.2.

    Check where that old compiler is located using: which tsc (or where tsc) and remove it.

    Try uninstalling the "global" typescript

    npm uninstall -g typescript
    

    Installing as part of a local dev dependency of your project

    npm install typescript --save-dev
    

    Execute it from the root of your project

    ./node_modules/.bin/tsc
    
    0 讨论(0)
  • 2020-12-09 02:48

    The issue was in my code.

    In large code base, issue was not clear.

    A simplified code is below:

    Bad:

     collection.insertMany(
        [[],
        function (err, result) {
        });
    

    Good:

    collection.insertMany(
        [],
        function (err, result) {
        });
    

    That is, the first one has [[], instead of normal array []

    TS error was not clear enough, and it showed error in the last line with });

    Hope this helps.

    0 讨论(0)
  • 2020-12-09 02:48

    I had today a similar error message. What was peculiar is that it did not break the Application. It was running smoothly but the command prompt (Windows machine) indicated there was an error. I did not update the Typescript version but found another culprit. It turned there was a tiny omission of symbol - closing ")", which I believe The Typescript is compensating for. Just for reference the code is the following:

    [new Object('First Characteristic','Second Characteristic',
    'Third Characteristic'*] 
    
    * notice here the ending ")" is missing.
    

    Once brought back no more issues on the command prompt!

    0 讨论(0)
  • 2020-12-09 02:49

    If you're getting error TS1005: 'finally' expected., it means you forgot to implement catch after try. Generally, it means the syntax you attempted to use was incorrect.

    0 讨论(0)
提交回复
热议问题