/
emptyAnonymousObjectNarrowing(strictnullchecks=false).symbols
139 lines (114 loc) · 4.29 KB
/
emptyAnonymousObjectNarrowing(strictnullchecks=false).symbols
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
=== tests/cases/compiler/emptyAnonymousObjectNarrowing.ts ===
declare let nonNull: {};
>nonNull : Symbol(nonNull, Decl(emptyAnonymousObjectNarrowing.ts, 0, 11))
if (nonNull === "foo") {
>nonNull : Symbol(nonNull, Decl(emptyAnonymousObjectNarrowing.ts, 0, 11))
nonNull;
>nonNull : Symbol(nonNull, Decl(emptyAnonymousObjectNarrowing.ts, 0, 11))
}
else {
nonNull;
>nonNull : Symbol(nonNull, Decl(emptyAnonymousObjectNarrowing.ts, 0, 11))
}
declare let obj: { a: string };
>obj : Symbol(obj, Decl(emptyAnonymousObjectNarrowing.ts, 8, 11))
>a : Symbol(a, Decl(emptyAnonymousObjectNarrowing.ts, 8, 18))
if (nonNull === obj) {
>nonNull : Symbol(nonNull, Decl(emptyAnonymousObjectNarrowing.ts, 0, 11))
>obj : Symbol(obj, Decl(emptyAnonymousObjectNarrowing.ts, 8, 11))
nonNull;
>nonNull : Symbol(nonNull, Decl(emptyAnonymousObjectNarrowing.ts, 0, 11))
}
else {
nonNull;
>nonNull : Symbol(nonNull, Decl(emptyAnonymousObjectNarrowing.ts, 0, 11))
}
function f1<T>(x: T) {
>f1 : Symbol(f1, Decl(emptyAnonymousObjectNarrowing.ts, 14, 1))
>T : Symbol(T, Decl(emptyAnonymousObjectNarrowing.ts, 16, 12))
>x : Symbol(x, Decl(emptyAnonymousObjectNarrowing.ts, 16, 15))
>T : Symbol(T, Decl(emptyAnonymousObjectNarrowing.ts, 16, 12))
if (nonNull === x) {
>nonNull : Symbol(nonNull, Decl(emptyAnonymousObjectNarrowing.ts, 0, 11))
>x : Symbol(x, Decl(emptyAnonymousObjectNarrowing.ts, 16, 15))
nonNull;
>nonNull : Symbol(nonNull, Decl(emptyAnonymousObjectNarrowing.ts, 0, 11))
}
else {
nonNull;
>nonNull : Symbol(nonNull, Decl(emptyAnonymousObjectNarrowing.ts, 0, 11))
}
}
function f2<T extends object>(x: T) {
>f2 : Symbol(f2, Decl(emptyAnonymousObjectNarrowing.ts, 23, 1))
>T : Symbol(T, Decl(emptyAnonymousObjectNarrowing.ts, 25, 12))
>x : Symbol(x, Decl(emptyAnonymousObjectNarrowing.ts, 25, 30))
>T : Symbol(T, Decl(emptyAnonymousObjectNarrowing.ts, 25, 12))
if (nonNull === x) {
>nonNull : Symbol(nonNull, Decl(emptyAnonymousObjectNarrowing.ts, 0, 11))
>x : Symbol(x, Decl(emptyAnonymousObjectNarrowing.ts, 25, 30))
nonNull;
>nonNull : Symbol(nonNull, Decl(emptyAnonymousObjectNarrowing.ts, 0, 11))
}
else {
nonNull;
>nonNull : Symbol(nonNull, Decl(emptyAnonymousObjectNarrowing.ts, 0, 11))
}
}
declare let union: "xyz" | { a: string } | undefined;
>union : Symbol(union, Decl(emptyAnonymousObjectNarrowing.ts, 34, 11))
>a : Symbol(a, Decl(emptyAnonymousObjectNarrowing.ts, 34, 28))
if (nonNull === union) {
>nonNull : Symbol(nonNull, Decl(emptyAnonymousObjectNarrowing.ts, 0, 11))
>union : Symbol(union, Decl(emptyAnonymousObjectNarrowing.ts, 34, 11))
nonNull;
>nonNull : Symbol(nonNull, Decl(emptyAnonymousObjectNarrowing.ts, 0, 11))
}
else {
nonNull;
>nonNull : Symbol(nonNull, Decl(emptyAnonymousObjectNarrowing.ts, 0, 11))
}
if (nonNull === undefined) {
>nonNull : Symbol(nonNull, Decl(emptyAnonymousObjectNarrowing.ts, 0, 11))
>undefined : Symbol(undefined)
nonNull;
>nonNull : Symbol(nonNull, Decl(emptyAnonymousObjectNarrowing.ts, 0, 11))
}
else {
nonNull;
>nonNull : Symbol(nonNull, Decl(emptyAnonymousObjectNarrowing.ts, 0, 11))
}
if (nonNull === null) {
>nonNull : Symbol(nonNull, Decl(emptyAnonymousObjectNarrowing.ts, 0, 11))
nonNull;
>nonNull : Symbol(nonNull, Decl(emptyAnonymousObjectNarrowing.ts, 0, 11))
}
else {
nonNull;
>nonNull : Symbol(nonNull, Decl(emptyAnonymousObjectNarrowing.ts, 0, 11))
}
if (nonNull == undefined) {
>nonNull : Symbol(nonNull, Decl(emptyAnonymousObjectNarrowing.ts, 0, 11))
>undefined : Symbol(undefined)
nonNull;
>nonNull : Symbol(nonNull, Decl(emptyAnonymousObjectNarrowing.ts, 0, 11))
}
else {
nonNull;
>nonNull : Symbol(nonNull, Decl(emptyAnonymousObjectNarrowing.ts, 0, 11))
}
// Repro from #50567
const foo = (value: unknown): string => {
>foo : Symbol(foo, Decl(emptyAnonymousObjectNarrowing.ts, 64, 5))
>value : Symbol(value, Decl(emptyAnonymousObjectNarrowing.ts, 64, 13))
if (!value) {
>value : Symbol(value, Decl(emptyAnonymousObjectNarrowing.ts, 64, 13))
return 'foo';
}
if (value === 'xyz') {
>value : Symbol(value, Decl(emptyAnonymousObjectNarrowing.ts, 64, 13))
return value; // Type '{}' is not assignable to type 'string'.
>value : Symbol(value, Decl(emptyAnonymousObjectNarrowing.ts, 64, 13))
}
return '';
};