Last active
November 6, 2018 04:10
-
-
Save Sammons/55e3a72b016535a334d17c42264105eb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function StrEnum<Elements extends string[]>(...elements: Elements) { | |
const result = {} as { [K in Elements[number]]: K }; | |
elements.forEach(e => { | |
(result as any)[e] = e | |
}); | |
return result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment