Alberto Cruz
Alberto Cruz

Reputation: 157

TypeScript error: ';' expected when using "let" keyword

I'm taking my first steps into TypeScript and discovered let keyword, which I found very helpful.

However, TypeScript compiler throws error TS1005: ';' expected. when trying to compile the following code:

let one = 1;

The command I use to compile is $ tsc file.tsc

Any help you can provide will be great!

Upvotes: 4

Views: 4773

Answers (3)

basarat
basarat

Reputation: 275867

You are using a really really old version of TypeScript (at least in TypeScript term of long) e.g. 1.0.1 will give that error as it does not understand let:

enter image description here

Please use a newer TypeScript version such as 1.8

enter image description here

Upvotes: 5

Sturdy
Sturdy

Reputation: 1

Follow this thread on stackoverflow to update the typescript and point to the right version in PATH. I faced the same issue even after updating the typescript because I had another version installed by Visual studio. And PATH was pointing to that old version like below.

  • C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.0\tsc.exe
  • C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.0\tsc.js

Open Cmd and do 'where tsc' , which shows the list of typescripts in the path then you can manually delete the typescript paths outside of nodejs. Credits - evilinside

Upvotes: 0

Rastislav Bodorik
Rastislav Bodorik

Reputation: 23

There was Environment path to Typescript 1.0 from Windows SDK on my machine. Removing that will solve this issue in VS Code terminal.

Upvotes: 0

Related Questions