4

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?

6
  • github.com/Microsoft/TypeScript/issues/4869 Commented Dec 22, 2015 at 10:10
  • Which ECMAScript version are you using ? 5 or 6 ? Commented Dec 22, 2015 at 10:15
  • Please add more details - i.e. TypeScript version and a longer snippet which provides the error. Commented Dec 22, 2015 at 10:20
  • Are you using Visual Studio ? If yes, did you update to the latest version of TypeScript (see visualstudiogallery.msdn.microsoft.com/…) Commented Dec 22, 2015 at 10:35
  • 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 Commented Dec 22, 2015 at 10:46

2 Answers 2

11

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Please let me know how you removed the older path from the environment? I ran into the exact same issue.
0

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.

1 Comment

Thanks. I fixed it. There was a problem in the JSON file

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.