- merge<ENUM_OBJECTS>(...enumObjects: ENUM_OBJECTS): ENUM_OBJECTS["length"] extends 0 ? Empty : ENUM_OBJECTS["length"] extends 1 ? ENUM_OBJECTS[0] : ENUM_OBJECTS["length"] extends 2 ? { [ KEY in keyof ENUM_OBJECTS[0] | keyof ENUM_OBJECTS[1]]: KEY extends keyof ENUM_OBJECTS[0] ? ENUM_OBJECTS[0][KEY] : ENUM_OBJECTS[1][KEY] } : ENUM_OBJECTS["length"] extends 3 ? { [ KEY in keyof ENUM_OBJECTS[0] | keyof ENUM_OBJECTS[1] | keyof ENUM_OBJECTS[2]]: KEY extends keyof ENUM_OBJECTS[0] ? ENUM_OBJECTS[0][KEY] : KEY extends keyof ENUM_OBJECTS[1] ? ENUM_OBJECTS[1][KEY] : ENUM_OBJECTS[2][KEY] } : ENUM_OBJECTS["length"] extends 4 ? { [ KEY in keyof ENUM_OBJECTS[0] | keyof ENUM_OBJECTS[1] | keyof ENUM_OBJECTS[2] | keyof ENUM_OBJECTS[3]]: KEY extends keyof ENUM_OBJECTS[0] ? ENUM_OBJECTS[0][KEY] : KEY extends keyof ENUM_OBJECTS[1] ? ENUM_OBJECTS[1][KEY] : KEY extends keyof ENUM_OBJECTS[2] ? ENUM_OBJECTS[2][KEY] : ENUM_OBJECTS[3][KEY] } : ENUM_OBJECTS["length"] extends 5 ? { [ KEY in keyof ENUM_OBJECTS[0] | keyof ENUM_OBJECTS[1] | keyof ENUM_OBJECTS[2] | keyof ENUM_OBJECTS[3] | keyof ENUM_OBJECTS[4]]: KEY extends keyof ENUM_OBJECTS[0] ? ENUM_OBJECTS[0][KEY] : KEY extends keyof ENUM_OBJECTS[1] ? ENUM_OBJECTS[1][KEY] : KEY extends keyof ENUM_OBJECTS[2] ? ENUM_OBJECTS[2][KEY] : KEY extends keyof ENUM_OBJECTS[3] ? ENUM_OBJECTS[3][KEY] : ENUM_OBJECTS[4][KEY] } : "too many enum objects, expand type"
-
Type Parameters
-
ENUM_OBJECTS extends any[]
Parameters
-
Rest
...enumObjects: ENUM_OBJECTS
Returns ENUM_OBJECTS["length"] extends 0 ? Empty : ENUM_OBJECTS["length"] extends 1 ? ENUM_OBJECTS[0] : ENUM_OBJECTS["length"] extends 2 ? { [ KEY in keyof ENUM_OBJECTS[0] | keyof ENUM_OBJECTS[1]]: KEY extends keyof ENUM_OBJECTS[0] ? ENUM_OBJECTS[0][KEY] : ENUM_OBJECTS[1][KEY] } : ENUM_OBJECTS["length"] extends 3 ? { [ KEY in keyof ENUM_OBJECTS[0] | keyof ENUM_OBJECTS[1] | keyof ENUM_OBJECTS[2]]: KEY extends keyof ENUM_OBJECTS[0] ? ENUM_OBJECTS[0][KEY] : KEY extends keyof ENUM_OBJECTS[1] ? ENUM_OBJECTS[1][KEY] : ENUM_OBJECTS[2][KEY] } : ENUM_OBJECTS["length"] extends 4 ? { [ KEY in keyof ENUM_OBJECTS[0] | keyof ENUM_OBJECTS[1] | keyof ENUM_OBJECTS[2] | keyof ENUM_OBJECTS[3]]: KEY extends keyof ENUM_OBJECTS[0] ? ENUM_OBJECTS[0][KEY] : KEY extends keyof ENUM_OBJECTS[1] ? ENUM_OBJECTS[1][KEY] : KEY extends keyof ENUM_OBJECTS[2] ? ENUM_OBJECTS[2][KEY] : ENUM_OBJECTS[3][KEY] } : ENUM_OBJECTS["length"] extends 5 ? { [ KEY in keyof ENUM_OBJECTS[0] | keyof ENUM_OBJECTS[1] | keyof ENUM_OBJECTS[2] | keyof ENUM_OBJECTS[3] | keyof ENUM_OBJECTS[4]]: KEY extends keyof ENUM_OBJECTS[0] ? ENUM_OBJECTS[0][KEY] : KEY extends keyof ENUM_OBJECTS[1] ? ENUM_OBJECTS[1][KEY] : KEY extends keyof ENUM_OBJECTS[2] ? ENUM_OBJECTS[2][KEY] : KEY extends keyof ENUM_OBJECTS[3] ? ENUM_OBJECTS[3][KEY] : ENUM_OBJECTS[4][KEY] } : "too many enum objects, expand type"
Creates a "merged" enum which can be used in
Enums.keys
,values
,entries
, etc with the same performance.Note that basic lookup will not be aware of new/deleted values until an
Enums
operation is called.