Skip to content

Commit

Permalink
Add missing type guard for is.enumCase
Browse files Browse the repository at this point in the history
Fixes #205
  • Loading branch information
sindresorhus committed May 16, 2024
1 parent f7148e1 commit 0df21e4
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion source/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ export function isEmptyStringOrWhitespace(value: unknown): value is string {
return isEmptyString(value) || isWhitespaceString(value);
}

export function isEnumCase<T = unknown>(value: unknown, targetEnum: T): boolean {
export function isEnumCase<T = unknown>(value: unknown, targetEnum: T): value is T[keyof T] {
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
return Object.values(targetEnum as any).includes(value as string);
}
Expand Down

0 comments on commit 0df21e4

Please sign in to comment.