@@ -85,3 +85,81 @@ namespace Problem4 {
85
85
>toUpperCase : Symbol(String.toUpperCase, Decl(lib.es5.d.ts, --, --))
86
86
}
87
87
}
88
+
89
+ namespace Problem5 {
90
+ >Problem5 : Symbol(Problem5, Decl(typeGuardNarrowsIndexedAccessOfAnyProperty.ts, 23, 1))
91
+
92
+ declare const obj: { [key: string]: string | undefined };
93
+ >obj : Symbol(obj, Decl(typeGuardNarrowsIndexedAccessOfAnyProperty.ts, 26, 15))
94
+ >key : Symbol(key, Decl(typeGuardNarrowsIndexedAccessOfAnyProperty.ts, 26, 24))
95
+
96
+ declare const key: string;
97
+ >key : Symbol(key, Decl(typeGuardNarrowsIndexedAccessOfAnyProperty.ts, 27, 15))
98
+
99
+ if (obj[key]) {
100
+ >obj : Symbol(obj, Decl(typeGuardNarrowsIndexedAccessOfAnyProperty.ts, 26, 15))
101
+ >key : Symbol(key, Decl(typeGuardNarrowsIndexedAccessOfAnyProperty.ts, 27, 15))
102
+
103
+ while(!!true) {
104
+ obj[key].toUpperCase() // should Ok
105
+ >obj[key].toUpperCase : Symbol(String.toUpperCase, Decl(lib.es5.d.ts, --, --))
106
+ >obj : Symbol(obj, Decl(typeGuardNarrowsIndexedAccessOfAnyProperty.ts, 26, 15))
107
+ >key : Symbol(key, Decl(typeGuardNarrowsIndexedAccessOfAnyProperty.ts, 27, 15))
108
+ >toUpperCase : Symbol(String.toUpperCase, Decl(lib.es5.d.ts, --, --))
109
+ }
110
+ }
111
+ }
112
+
113
+ namespace Problem6 {
114
+ >Problem6 : Symbol(Problem6, Decl(typeGuardNarrowsIndexedAccessOfAnyProperty.ts, 33, 1))
115
+
116
+ declare const obj: { [key: string]: string | undefined };
117
+ >obj : Symbol(obj, Decl(typeGuardNarrowsIndexedAccessOfAnyProperty.ts, 36, 15))
118
+ >key : Symbol(key, Decl(typeGuardNarrowsIndexedAccessOfAnyProperty.ts, 36, 24))
119
+
120
+ declare const key: string;
121
+ >key : Symbol(key, Decl(typeGuardNarrowsIndexedAccessOfAnyProperty.ts, 37, 15))
122
+
123
+ while(!!true) {
124
+ if (obj[key]) {
125
+ >obj : Symbol(obj, Decl(typeGuardNarrowsIndexedAccessOfAnyProperty.ts, 36, 15))
126
+ >key : Symbol(key, Decl(typeGuardNarrowsIndexedAccessOfAnyProperty.ts, 37, 15))
127
+
128
+ obj[key].toUpperCase() // should Ok
129
+ >obj[key].toUpperCase : Symbol(String.toUpperCase, Decl(lib.es5.d.ts, --, --))
130
+ >obj : Symbol(obj, Decl(typeGuardNarrowsIndexedAccessOfAnyProperty.ts, 36, 15))
131
+ >key : Symbol(key, Decl(typeGuardNarrowsIndexedAccessOfAnyProperty.ts, 37, 15))
132
+ >toUpperCase : Symbol(String.toUpperCase, Decl(lib.es5.d.ts, --, --))
133
+ }
134
+ }
135
+ }
136
+
137
+ namespace Problem7 {
138
+ >Problem7 : Symbol(Problem7, Decl(typeGuardNarrowsIndexedAccessOfAnyProperty.ts, 43, 1))
139
+
140
+ declare const obj: { [key: string]: string | undefined };
141
+ >obj : Symbol(obj, Decl(typeGuardNarrowsIndexedAccessOfAnyProperty.ts, 46, 15))
142
+ >key : Symbol(key, Decl(typeGuardNarrowsIndexedAccessOfAnyProperty.ts, 46, 24))
143
+
144
+ declare const key: string;
145
+ >key : Symbol(key, Decl(typeGuardNarrowsIndexedAccessOfAnyProperty.ts, 47, 15))
146
+
147
+ if (obj[key]) {
148
+ >obj : Symbol(obj, Decl(typeGuardNarrowsIndexedAccessOfAnyProperty.ts, 46, 15))
149
+ >key : Symbol(key, Decl(typeGuardNarrowsIndexedAccessOfAnyProperty.ts, 47, 15))
150
+
151
+ while(!!true) {
152
+ obj[key].toUpperCase() // should error
153
+ >obj[key].toUpperCase : Symbol(String.toUpperCase, Decl(lib.es5.d.ts, --, --))
154
+ >obj : Symbol(obj, Decl(typeGuardNarrowsIndexedAccessOfAnyProperty.ts, 46, 15))
155
+ >key : Symbol(key, Decl(typeGuardNarrowsIndexedAccessOfAnyProperty.ts, 47, 15))
156
+ >toUpperCase : Symbol(String.toUpperCase, Decl(lib.es5.d.ts, --, --))
157
+
158
+ obj[key] = undefined
159
+ >obj : Symbol(obj, Decl(typeGuardNarrowsIndexedAccessOfAnyProperty.ts, 46, 15))
160
+ >key : Symbol(key, Decl(typeGuardNarrowsIndexedAccessOfAnyProperty.ts, 47, 15))
161
+ >undefined : Symbol(undefined)
162
+ }
163
+ }
164
+ }
165
+
0 commit comments