打字稿错误 TS1005: ';'预期(二) [英] TypeScript error TS1005: ';' expected (II)
问题描述
首先,我已经看过其他关于错误 TS1005 的帖子.相同的错误代码,但完全不同.
First of all, I've already seen the other posts about error TS1005. Same error code, but totally different.
一个简单的let x: number;
会在编译过程中产生error TS1005
.这与错误消息所说的缺少分号无关,而是编译器无法识别 let 关键字.我读到这可能是因为一个过时的编译器.
A simple let x: number;
will generate the error TS1005
during compilation. It's not about a missing semicolon as what the error message says, but the compiler does not recognize the let keyword. I read that maybe because of an outdated compiler.
这是我使用 npm install -g typescript
- TypeScript 版本:
2.5.2
- 编译器 (tsc) 版本:
1.0.3.0
也许有人可以帮忙?
推荐答案
您的安装有误;您使用的是非常旧的编译器版本 (1.0.3.0).
Your installation is wrong; you are using a very old compiler version (1.0.3.0).
tsc --version
应该返回 2.5.2 的版本.
tsc --version
should return a version of 2.5.2.
使用以下命令检查旧编译器的位置:which tsc
(或where tsc
)并将其删除.
Check where that old compiler is located using: which tsc
(or where tsc
) and remove it.
尝试卸载全局"打字稿
npm uninstall -g typescript
作为项目的本地开发依赖项的一部分进行安装
Installing as part of a local dev dependency of your project
npm install typescript --save-dev
从项目的根目录执行
./node_modules/.bin/tsc
这篇关于打字稿错误 TS1005: ';'预期(二)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!