Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
721 views
in Technique[技术] by (71.8m points)

TypeScript error TS1005: ';' expected (II)

First of all, I've already seen the other posts about error TS1005. Same error code, but totally different.

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.

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.

Check where that old compiler is located using: which tsc (or where 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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...