-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Expand file tree
/
Copy pathdiscriminantPropertyInference.symbols
More file actions
120 lines (90 loc) · 4.48 KB
/
discriminantPropertyInference.symbols
File metadata and controls
120 lines (90 loc) · 4.48 KB
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
=== tests/cases/compiler/discriminantPropertyInference.ts ===
// Repro from #41759
type DiscriminatorTrue = {
>DiscriminatorTrue : Symbol(DiscriminatorTrue, Decl(discriminantPropertyInference.ts, 0, 0))
disc: true;
>disc : Symbol(disc, Decl(discriminantPropertyInference.ts, 2, 26))
cb: (x: string) => void;
>cb : Symbol(cb, Decl(discriminantPropertyInference.ts, 3, 15))
>x : Symbol(x, Decl(discriminantPropertyInference.ts, 4, 9))
}
type DiscriminatorFalse = {
>DiscriminatorFalse : Symbol(DiscriminatorFalse, Decl(discriminantPropertyInference.ts, 5, 1))
disc?: false;
>disc : Symbol(disc, Decl(discriminantPropertyInference.ts, 7, 27))
cb: (x: number) => void;
>cb : Symbol(cb, Decl(discriminantPropertyInference.ts, 8, 17))
>x : Symbol(x, Decl(discriminantPropertyInference.ts, 9, 9))
}
type Unrelated = {
>Unrelated : Symbol(Unrelated, Decl(discriminantPropertyInference.ts, 10, 1))
val: number;
>val : Symbol(val, Decl(discriminantPropertyInference.ts, 12, 18))
}
declare function f(options: DiscriminatorTrue | DiscriminatorFalse): any;
>f : Symbol(f, Decl(discriminantPropertyInference.ts, 14, 1))
>options : Symbol(options, Decl(discriminantPropertyInference.ts, 16, 19))
>DiscriminatorTrue : Symbol(DiscriminatorTrue, Decl(discriminantPropertyInference.ts, 0, 0))
>DiscriminatorFalse : Symbol(DiscriminatorFalse, Decl(discriminantPropertyInference.ts, 5, 1))
// simple inference
f({
>f : Symbol(f, Decl(discriminantPropertyInference.ts, 14, 1))
disc: true,
>disc : Symbol(disc, Decl(discriminantPropertyInference.ts, 19, 3))
cb: s => parseInt(s)
>cb : Symbol(cb, Decl(discriminantPropertyInference.ts, 20, 15))
>s : Symbol(s, Decl(discriminantPropertyInference.ts, 21, 7))
>parseInt : Symbol(parseInt, Decl(lib.es5.d.ts, --, --))
>s : Symbol(s, Decl(discriminantPropertyInference.ts, 21, 7))
});
// simple inference
f({
>f : Symbol(f, Decl(discriminantPropertyInference.ts, 14, 1))
disc: false,
>disc : Symbol(disc, Decl(discriminantPropertyInference.ts, 25, 3))
cb: n => n.toFixed()
>cb : Symbol(cb, Decl(discriminantPropertyInference.ts, 26, 16))
>n : Symbol(n, Decl(discriminantPropertyInference.ts, 27, 7))
>n.toFixed : Symbol(Number.toFixed, Decl(lib.es5.d.ts, --, --))
>n : Symbol(n, Decl(discriminantPropertyInference.ts, 27, 7))
>toFixed : Symbol(Number.toFixed, Decl(lib.es5.d.ts, --, --))
});
// simple inference when strict-null-checks are enabled
f({
>f : Symbol(f, Decl(discriminantPropertyInference.ts, 14, 1))
disc: undefined,
>disc : Symbol(disc, Decl(discriminantPropertyInference.ts, 31, 3))
>undefined : Symbol(undefined)
cb: n => n.toFixed()
>cb : Symbol(cb, Decl(discriminantPropertyInference.ts, 32, 20))
>n : Symbol(n, Decl(discriminantPropertyInference.ts, 33, 7))
>n.toFixed : Symbol(Number.toFixed, Decl(lib.es5.d.ts, --, --))
>n : Symbol(n, Decl(discriminantPropertyInference.ts, 33, 7))
>toFixed : Symbol(Number.toFixed, Decl(lib.es5.d.ts, --, --))
});
// requires checking type information since discriminator is missing from object
f({
>f : Symbol(f, Decl(discriminantPropertyInference.ts, 14, 1))
cb: n => n.toFixed()
>cb : Symbol(cb, Decl(discriminantPropertyInference.ts, 37, 3))
>n : Symbol(n, Decl(discriminantPropertyInference.ts, 38, 7))
>n.toFixed : Symbol(Number.toFixed, Decl(lib.es5.d.ts, --, --))
>n : Symbol(n, Decl(discriminantPropertyInference.ts, 38, 7))
>toFixed : Symbol(Number.toFixed, Decl(lib.es5.d.ts, --, --))
});
declare function g(options: DiscriminatorTrue | DiscriminatorFalse | Unrelated): any;
>g : Symbol(g, Decl(discriminantPropertyInference.ts, 39, 3))
>options : Symbol(options, Decl(discriminantPropertyInference.ts, 42, 19))
>DiscriminatorTrue : Symbol(DiscriminatorTrue, Decl(discriminantPropertyInference.ts, 0, 0))
>DiscriminatorFalse : Symbol(DiscriminatorFalse, Decl(discriminantPropertyInference.ts, 5, 1))
>Unrelated : Symbol(Unrelated, Decl(discriminantPropertyInference.ts, 10, 1))
// requires checking properties of all types, rather than properties of just the union type (e.g. only intersection)
g({
>g : Symbol(g, Decl(discriminantPropertyInference.ts, 39, 3))
cb: n => n.toFixed()
>cb : Symbol(cb, Decl(discriminantPropertyInference.ts, 45, 3))
>n : Symbol(n, Decl(discriminantPropertyInference.ts, 46, 7))
>n.toFixed : Symbol(Number.toFixed, Decl(lib.es5.d.ts, --, --))
>n : Symbol(n, Decl(discriminantPropertyInference.ts, 46, 7))
>toFixed : Symbol(Number.toFixed, Decl(lib.es5.d.ts, --, --))
});