Take a look at the following code snippet:
export enum ResponseCodes {
'Network error' = 5003
}
const code: ResponseCodes = 4000 // This does not result in an error
- Even though the specified key is not present in the enum, why does it not throw an error?
- Is there a way to enforce using this syntax instead:
const code: ResponseCodes = ResponseCodes['Network error']