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:
Severity Code Description Project File Line Suppression State Error TS2322 Type '"E"' is not assignable to type 'StepType'. ClientApp (tsconfig project) Z:\SMART\Smart\Smart\ClientApp\app\models\process.model.ts 17 Active Error TS2322 Type '"S"' is not assignable to type 'StepType'. ClientApp (tsconfig project) Z:\SMART\Smart\Smart\ClientApp\app\models\process.model.ts 14 Active Error TS2322 Type '"A"' is not assignable to type 'StepType'. ClientApp (tsconfig project) Z:\SMART\Smart\Smart\ClientApp\app\models\process.model.ts 15 Active Error TS2322 Type '"D"' is not assignable to type 'StepType'. ClientApp (tsconfig project) Z:\SMART\Smart\Smart\ClientApp\app\models\process.model.ts 16 Active
The error messages apply to the following code snippet (with the line numbers):
13. export enum StepType {
14. Start = 'S',
15. Activity = 'A',
16. Decision = 'D',
17. End = 'E'
18. }
I am using Visual Studio 2017 which claims TypeScript 2.4.0 is installed:
I searched through TypeScript's issues, but without luck. Does anybody know how to fix it?
Inspired by Duncan's answer, I found the root cause. Although the application was using TypeScript 2.4, VS's IntelliSense was still stuck in 2.3.
The way to resolve the issue was to download and install TypeScript 2.4 SDK and then select from the options the newer version: