I'm completely new to Angular2 and TypeScript. I'm following Tutorial but I keep coping this error. Is it an error caused by the compiler or something?
If you use IntelliJ as your IDE and are getting the "Declaration or statement expected" error, try closing and re-opening the file or restarting your IDE as it sometimes glitches. Make sure you aren't using any reserved words when declaring variables.
Typescript ERROR TS1128: Declaration or statement expected. 201. Angular CLI Error: The serve command requires to be run in an Angular project, but a project definition could not be found. 174.
The "Expression expected" TypeScript error occurs when we have a syntax error in our code or our code editor is using an older version of TypeScript. To solve the error, make sure to correct and syntax errors and use a recent version of the TypeScript compiler.
It looks like you are using an older version of the compiler.
You need to download and install the TypeScript 1.5 beta (or newer) in order to use ES6 style imports and annotations.
You can check the version you currently have installed using:
tsc --version
It should give you Version 1.5.0-beta
.
If you already have it installed, perhaps your PATH
variable still points to the old folder, so edit your PATH variable to point to the latest folder, i.e.
C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.5\;
Since you didn't accept the answer, I assume you are on OSx?
I had 2 instances of TS installed on my machine, I needed to point to the correct/newer one. Try this:
In Webstorm goto Preferences (Command + ,) -> Languages -> Typescript.
Command Line Options:
-m amd -t ES5
Compiler Versions:
/usr/local/lib/node_modules/typescript/lib
This way it will grab your global typescript instead of the one Webstorm may have set to default for you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With