TS2567

error TS2567: Enum declarations can only merge with namespace or other enum declarations. lib.dom.d.ts(18299, 6): ‘ResponseType’ was also declared here.

Broken Code ❌

1
2
3
4
enum ResponseType {
ACTIVE,
ERROR,
}

Fixed Code ✔️

In the broken code shown above, a type ResponseType is already declared as part of the “dom” typings. Enums can be merged with other enums but since the other declaration of ResponseType is a type, we cannot merge the existing declaration with our custom one. That’s why we have to remove “dom” from the “lib” entries in our “tsconfig.json” file or use a different name for our enum:

1
2
3
4
enum MyResponseType {
ACTIVE,
ERROR,
}