/
assertionFunctionWildcardImport2.types
50 lines (41 loc) · 1.28 KB
/
assertionFunctionWildcardImport2.types
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
47
48
49
50
=== tests/cases/compiler/asserts.ts ===
function isNonNullable<T>(obj: T): asserts obj is NonNullable<T> {
>isNonNullable : <T>(obj: T) => asserts obj is NonNullable<T>
>obj : T
if (obj === undefined || obj === null) {
>obj === undefined || obj === null : boolean
>obj === undefined : boolean
>obj : T
>undefined : undefined
>obj === null : boolean
>obj : T & ({} | null)
>null : null
throw new Error("Must not be a nullable value");
>new Error("Must not be a nullable value") : Error
>Error : ErrorConstructor
>"Must not be a nullable value" : "Must not be a nullable value"
}
}
export {
isNonNullable
>isNonNullable : <T>(obj: T) => asserts obj is NonNullable<T>
};
=== tests/cases/compiler/test.ts ===
import * as asserts from "./asserts";
>asserts : typeof asserts
function test(obj: string | null): void {
>test : (obj: string | null) => void
>obj : string | null
>null : null
asserts.isNonNullable(obj);
>asserts.isNonNullable(obj) : void
>asserts.isNonNullable : <T>(obj: T) => asserts obj is NonNullable<T>
>asserts : typeof asserts
>isNonNullable : <T>(obj: T) => asserts obj is NonNullable<T>
>obj : string | null
obj.trim();
>obj.trim() : string
>obj.trim : () => string
>obj : string
>trim : () => string
}