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

  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
回答: 错误TS1005: '=' expected通常是由于语法错误导致的。根据引用\[1\]和引用\[2\]的内容,这个错误可能是由于TypeScript编译器版本太低或环境变量配置不正确引起的。你可以通过以下步骤来解决这个问题: 1. 检查你当前安装的TypeScript版本,可以使用命令"tsc -v"来查看。如果版本太低,可以尝试升级到最新版本。你可以使用命令"npm uninstall typescript"卸载旧版本,然后使用命令"npm install -g typescript@latest"安装最新版本。 2. 检查你的环境变量配置,确保TypeScript的路径正确。根据引用\[2\]的内容,你可以将环境变量中的TypeScript版本改为2.5,并重启VSCode。 3. 如果以上步骤都没有解决问题,你可以尝试完全删除电脑上的TypeScript环境,并重新安装最新版本。根据引用\[3\]的内容,你可以删除TypeScript文件夹,然后重新安装。 希望以上解决方案能帮助你解决TS1005错误。如果问题仍然存在,请提供更多详细信息以便我们进一步帮助你。 #### 引用[.reference_title] - *1* *3* [解决TypeScript error TS1005: ‘;‘ expected](https://blog.csdn.net/weixin_44631419/article/details/129660310)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item] - *2* [vscode中运行ts报错 error TS1005: ‘;‘ expected.](https://blog.csdn.net/adminkeys/article/details/113142908)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值