Cast int to enum strings in Typescript

Enums in TypeScript are numbers at runtime, so message.type will be 0, 1, 2 or 3.

To get the string value, you need to pass that number into the enum as an index:

Type[0] // "Info"

So, in your example, you’ll need to do this:

Type[message.type] // "Info" when message.type is 0

Docs

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)