Skip to content

Commit d24f029

Browse files
committed
🌿 Add test that fails with #49
1 parent cb4fd96 commit d24f029

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

is_test.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -997,6 +997,17 @@ Deno.test("isOneOf<T>", async (t) => {
997997
assertType<Equal<typeof a, number | string | boolean>>(true);
998998
}
999999
});
1000+
await t.step("returns proper type predicate (#49)", () => {
1001+
const isFoo = isObjectOf({ foo: isString });
1002+
const isBar = isObjectOf({ foo: isString, bar: isNumber });
1003+
type Foo = PredicateType<typeof isFoo>;
1004+
type Bar = PredicateType<typeof isBar>;
1005+
const preds = [isFoo, isBar];
1006+
const a: unknown = [0, "a", true];
1007+
if (isOneOf(preds)(a)) {
1008+
assertType<Equal<typeof a, Foo | Bar>>(true);
1009+
}
1010+
});
10001011
await t.step("returns true on one of T", () => {
10011012
const preds = [isNumber, isString, isBoolean];
10021013
assertEquals(isOneOf(preds)(0), true);

0 commit comments

Comments
 (0)