Skip to content

Commit c9baebf

Browse files
committed
Change signature of isType to allow any
There's no need to restrict the type of argument being tested. In particular, this is convenient for nullable strings.
1 parent d3f308b commit c9baebf

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ unnecessary for most users. There are still a few niche reasons why users may
348348
still prefer to use this library.
349349

350350
* This library provides several helper functions which cannot easy be
351-
implemented for native enums. Of these, `Enum.isType()` will likely be the
351+
implemented for native enums. Of these, [`Enum.isType()`](#enumistypeenum-value) will likely be the
352352
most useful.
353353
* Defining a native string enum involves a bit of repetition, as each value must
354354
be written twice:

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export namespace Enum {
4646

4747
export function isType<
4848
T extends { [_: string]: any }
49-
>(e: T, value: string): value is Enum<T> {
49+
>(e: T, value: any): value is Enum<T> {
5050
return values(e).indexOf(value) !== -1;
5151
}
5252
}

0 commit comments

Comments
 (0)