Skip to content

Commit

Permalink
Merge 1f4f7ba into 6c27285
Browse files Browse the repository at this point in the history
  • Loading branch information
Cory Cook committed Sep 12, 2018
2 parents 6c27285 + 1f4f7ba commit 6981e13
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/lib/enum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,11 @@ const enumTypeMap = new Map();
* instance referencing the enum.
* This may not match the name in the code so you can call
* this function directly to define the enum before it is used.
* @param {string} name
* @param {T} target
* @returns {T}
* @template T
*/
export function createEnum(name, target) {
export function createEnum<T extends { [key: string]: any }>(
name: string,
target: T
): T {
const values = Object.keys(target)
.filter(key => isNaN(Number(key))) // eslint-disable-line no-restricted-globals
.reduce(
Expand Down

0 comments on commit 6981e13

Please sign in to comment.