Difference between string enums and string literal types in TS

The key thing to understand is that the values of string enums are opaque.

The intended use case for a string enum is that you don’t want other code to know or care what the literal string backing MyKeyType.FOO is. This means that you won’t be able to, say, pass the literal string "bar" to a function accepting a MyKeyType — you’ll have to write MyKeyType.BAR instead.

Leave a Comment

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