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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值