[英]typeScript error 'module, class, interface, enum, import or statement' expected
I'm trying to understand why this line invokes an error: 我试图理解为什么这一行会引发错误:
const value = 20 * 30;
error TS1008: Unexpected token; 错误TS1008:意外令牌; 'module, class, interface, enum, import or statement' expected. 预期为“模块,类,接口,枚举,导入或声明”。
any idea? 任何想法?
Here is the solution: 解决方法如下:
Earlier on my machine I had installed Visual Studio 2015 Pro Edition. 之前,我在计算机上安装了Visual Studio 2015 Pro Edition。 that had installed TypeScript 1.0.3.0. 已安装TypeScript 1.0.3.0。 and added its path to system environment. 并将其路径添加到系统环境。
Now I used npm install -g TypeScript
and it did install, however from command line, typing tsc --version
was always giving 1.0.3.0. 现在,我使用npm install -g TypeScript
并成功安装,但是从命令行键入tsc --version
始终提供1.0.3.0。
I removed the older path from environment and then restarted code and it worked fine. 我从环境中删除了较旧的路径,然后重新启动了代码,它工作正常。
Better you check your versions and the solution might help. 更好地检查版本,该解决方案可能会有所帮助。
It doesn't cause an error for me: https://jsfiddle.net/n0w1jt7b/ 它不会对我造成错误: https : //jsfiddle.net/n0w1jt7b/
const value = 20 * 30; // 600
Be sure that all your versions are up-to-date. 确保所有版本都是最新的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.