-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathassert_non_nullable_test.ts
46 lines (41 loc) · 1.02 KB
/
assert_non_nullable_test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import { assertNonNullable } from "./assert_non_nullable.ts";
import { defineTable, doAssert } from "./_fixture.ts";
import { assertType, IsExact } from "./_dev_deps.ts";
Deno.test({
name: "assertNonNullable",
fn: () => {
defineTable({
"() => {}": true,
"-1": true,
"0": true,
1: true,
"": true,
"[[]]": true,
"[]": true,
"big1": true,
"error": true,
"false": true,
"function": true,
"map": true,
"promise": true,
"set": true,
"string": true,
"true": true,
"weakMap": true,
"weakSet": true,
"{{}}": true,
"{}": true,
symbol: true,
}).forEach(doAssert(assertNonNullable));
},
});
Deno.test("should infer {}", () => {
const input: unknown = {};
assertNonNullable(input);
assertType<IsExact<typeof input, {}>>(true);
});
Deno.test("should infer non-nullable", () => {
const input: null | undefined | string = "";
assertNonNullable(input);
assertType<IsExact<typeof input, string>>(true);
});