score:9

Accepted answer
  user.security[securityKey as SecurityMode]

The problem is not the type of user.security but the type of securityKey as that can be any string, also one that isn't part of user.security. As undefined / false have the same meaning here (I assume), it is safe to cast the string to the string literal union type, then the error should disappear.


Related Query

More Query from same tag