TypeScript error TS1005: ';' expected

https://stackoverflow.com/questions/46398916/typescr

Ask Question

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

I was excited to try out TypeScript but was disappointed. A simple let x: number; will generate the error TS1005 during compilation. It's not about a missing semicolon as what the error msg says, but the compiler does not recognize the let keyword. I read that maybe because of an outdated compiler. Here's my typescript version installed using npm install -g typescript

  • TypeScript version: 2.5.2
  • Compiler (tsc) version: 1.0.3.0

Maybe somebody can help? Thank you.

 

 

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.

On linux, OSX, check where that old compiler is located using: which 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

shareimprove this answer

edited Jun 11 '18 at 17:42

answered Sep 25 '17 at 7:24

Bruno Grieder

16k33 gold badges4040 silver badges7171 bronze badges

add a comment

9

 

On Windows you can have in your PATH

PATH = ...;C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.0\; ...

remove it from PATH env, then

npm install -g typescript@latest

it worked for me to solve the

"TypeScript error TS1005: ';' expected"

 

 

You haven't the last version of typescript.

Running npm install -g typescriptnpm checks if tsc command is already installed. And it might be, by another software like Visual Studio. If so, npm doesn't override it. So you have to remove the previous deprecated tsc installed command. Run where tsc to know its bin location. It should be in C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.0\ in windows. Once found, delete the folder, and re-run npm install -g typescript. This should now install the last version of typescript.

shareimprove this answer

answered Jan 31 '18 at 21:11

Yairopro

2,2691616 silver badges2626 bronze badges

add a comment

ipt-error-ts1005-expected

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章