我最近将TypeScript版本从2.3.4升级到2.4.0,希望能够使用字符串枚举。然而,令我失望的是,我遇到了以下错误信息:
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
错误信息适用于以下代码片段(带有行号):13. export enum StepType {
14. Start = 'S',
15. Activity = 'A',
16. Decision = 'D',
17. End = 'E'
18. }
我正在使用声称安装了TypeScript 2.4.0的Visual Studio 2017:
我在TypeScript的问题中进行了搜索,但没有结果。 有人知道如何解决吗?
process.model.ts
文件中并没有包含StepType
定义,而是使用该枚举的代码。 - rzelek