TypeScript 的字符串枚举

编程入门 行业动态 更新时间:2024-10-27 17:20:32
本文介绍了TypeScript 的字符串枚举 - “类型 ... 不可分配给类型 ...";的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我最近将 TypeScript 的版本从 2.3.4 升级到 2.4.0 希望能使用

我搜索了

解决问题的方法是下载并安装

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:SMARTSmartSmartClientAppappmodelsprocess.model.ts 17 Active Error TS2322 Type '"S"' is not assignable to type 'StepType'. ClientApp (tsconfig project) Z:SMARTSmartSmartClientAppappmodelsprocess.model.ts 14 Active Error TS2322 Type '"A"' is not assignable to type 'StepType'. ClientApp (tsconfig project) Z:SMARTSmartSmartClientAppappmodelsprocess.model.ts 15 Active Error TS2322 Type '"D"' is not assignable to type 'StepType'. ClientApp (tsconfig project) Z:SMARTSmartSmartClientAppappmodelsprocess.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

The way to resolve the issue was to download and install TypeScript 2.4 SDK and then select from the options the newer version:

更多推荐

TypeScript 的字符串枚举

本文发布于:2023-11-14 02:34:50,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1585994.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:字符串   TypeScript

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!