Skip to content

Commit

Permalink
fix TS errors in stringEnum utility type
Browse files Browse the repository at this point in the history
  • Loading branch information
janmonschke committed Feb 19, 2024
1 parent 8789f21 commit 177f8c9
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions x-pack/plugins/security_solution/common/utility_types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,11 @@ type NonAny = number | boolean | string | symbol | null;
export const unionWithNullType = <T extends runtimeTypes.Mixed>(type: T) =>
runtimeTypes.union([type, runtimeTypes.null]);

export const stringEnum = <T>(enumObj: T, enumName = 'enum') =>
export const stringEnum = <T extends object>(enumObj: T, enumName = 'enum') =>
new runtimeTypes.Type<T[keyof T], string>(
enumName,
// @ts-expect-error upgrade typescript v4.9.5
(u): u is T[keyof T] => Object.values(enumObj).includes(u),
(u, c) =>
// @ts-expect-error upgrade typescript v4.9.5
Object.values(enumObj).includes(u)
? runtimeTypes.success(u as T[keyof T])
: runtimeTypes.failure(u, c),
Expand Down

0 comments on commit 177f8c9

Please sign in to comment.