I have recently upgraded the version of TypeScript from 2.3.4 to 2.4.0 hoping to use the string enums. To my dismay, however, I have been greeted with the error messages:
For me, the problem was that @angular/cli
was using a lower version of Typescript. Check out your lock file. It was showing a requirement of <2.4.0. Our project uses yarn.lock
, for example.
When it compiled, it was throwing an error related to the lower version of Typescript. To fix the problem, I added the compatible flag ^
to the front. So for us, it started as:
"@angular/cli": "1.2.5"
...changed to:
"@angular/cli": "^1.2.5"
This seems to fix the issue. It's worth noting that it essentially forces cli
to use the workspace version of Typescript. For us, this is 2.4.0
, which this version of cli
isn't technically compatible with (since it requires <2.4.0). It throws a warning when compiling, but it has worked successfully for us for the time being.