tsc hello.ts

E:\source\develop\typescript\typescriptstudy\hello.ts(5,5): error TS1005: ';' expected.

实际测试 发现 把let换成var即不会报该错误。
网上查阅资料得知错误消息说的不是错误的分号,而是编译器无法识别let关键字。

运行tsc -v
发现版本是1.0.3.0

然后在网上得知typescript是在1.4 支持let语法。就打开windows 环境变量,看看tsc 是用到哪里的命令,是不是版本不对。

在windows环境变量内path 中发现下列语句:
C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.0;
貌似用到的是系统自带的1.0 。

这里将该环境变量删除。顺便也将路径下的typescript 1.0删除即可。在重新安装一下

npm install -g typescript@latest

即没有报上诉错误了
最后运行一下:
tsc -v
发现这次不是1.0.3.0了而是最新安装的3.8.3 。没问题了。

环境:vscode 3.4.3ts 3.8.3tsc 1.0.3.0function sayHello(person: string) { return 'Hello, ' + person;}let user = 'Tom'console.log(sayHello(user));hello.tstsc hello.ts报错E:\source\develop\type... 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 ...
报错:Uncaught SyntaxError: Unexpected token o in JSON at position 1 at JSON.parse (<anonymous>) at Function.m.parseJSON (jquery.js:8515) at Object.success (crud.html:45) at j (jquery.js:3143) at Object.fireWith [as resolveWith] (jquery.js:3255) at x (jquery.js:9309) at XMLHttpRequest.b (jquery.js:9713