Accepted answer[securityKey as SecurityMode]

The problem is not the type of but the type of securityKey as that can be any string, also one that isn't part of 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