4
votes

I'm trying to understand why this line invokes an error:

const value = 20 * 30;

error TS1008: Unexpected token; 'module, class, interface, enum, import or statement' expected.

any idea?

2
Which ECMAScript version are you using ? 5 or 6 ? - Alex
Please add more details - i.e. TypeScript version and a longer snippet which provides the error. - Martin Vseticka
Are you using Visual Studio ? If yes, did you update to the latest version of TypeScript (see visualstudiogallery.msdn.microsoft.com/…) - Alex
When running tsc version I get : Version 1.0.3.0 and when running where tsc I get: 1.0 and 1.7 versions. I added 1.7 in PATH variables - Dusty

2 Answers

10
votes

Here is the solution:

Earlier on my machine I had installed Visual Studio 2015 Pro Edition. that had installed 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.

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.

0
votes

It doesn't cause an error for me: https://jsfiddle.net/n0w1jt7b/

const value = 20 * 30; // 600

Be sure that all your versions are up-to-date.