Skip to content

Instantly share code, notes, and snippets.

@ikasoba
Created July 12, 2022 09:10
Show Gist options
  • Select an option

  • Save ikasoba/ba4981cead4c1d3418a9789f85f46663 to your computer and use it in GitHub Desktop.

Select an option

Save ikasoba/ba4981cead4c1d3418a9789f85f46663 to your computer and use it in GitHub Desktop.
create enum like object from string[]
const createEnum = <T extends string|number>(a:readonly T[]|T[]): {[K in T]: K} => Object.fromEntries<T>(a.map(x => [x,x])) as any;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment