Skip to content

Commit d182a59

Browse files
committed
Fix comments in tests
1 parent a57ee29 commit d182a59

4 files changed

Lines changed: 27 additions & 39 deletions

File tree

tests/baselines/reference/typeGuardIntersectionTypes.js

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,14 @@ function identifyBeast(beast: Beast) {
7171

7272
// All winged beasts with legs
7373
if (hasWings(beast)) {
74-
if (beast.legs === 4) { // ERROR TS2339: Property 'legs' does not exist on type 'Winged'.
74+
if (beast.legs === 4) {
7575
log(`pegasus - 4 legs, wings`);
7676
}
77-
else if (beast.legs === 2) { // ERROR TS2339...
77+
else if (beast.legs === 2) {
7878
log(`bird - 2 legs, wings`);
7979
}
8080
else {
81-
log(`unknown - ${beast.legs} legs, wings`); // ERROR TS2339...
81+
log(`unknown - ${beast.legs} legs, wings`);
8282
}
8383
}
8484

@@ -101,16 +101,14 @@ function identifyBeast(beast: Beast) {
101101

102102
function beastFoo(beast: Object) {
103103
if (hasWings(beast) && hasLegs(beast)) {
104-
beast // beast is Legged
105-
// ideally, beast would be Winged && Legged here...
104+
beast; // Winged & Legged
106105
}
107106
else {
108-
beast
107+
beast;
109108
}
110109

111110
if (hasLegs(beast) && hasWings(beast)) {
112-
beast // beast is Winged
113-
// ideally, beast would be Legged && Winged here...
111+
beast; // Legged & Winged
114112
}
115113
}
116114

@@ -152,7 +150,7 @@ function identifyBeast(beast) {
152150
log("bird - 2 legs, wings");
153151
}
154152
else {
155-
log("unknown - " + beast.legs + " legs, wings"); // ERROR TS2339...
153+
log("unknown - " + beast.legs + " legs, wings");
156154
}
157155
}
158156
else {
@@ -170,12 +168,12 @@ function identifyBeast(beast) {
170168
}
171169
function beastFoo(beast) {
172170
if (hasWings(beast) && hasLegs(beast)) {
173-
beast; // beast is Legged
171+
beast; // Winged & Legged
174172
}
175173
else {
176174
beast;
177175
}
178176
if (hasLegs(beast) && hasWings(beast)) {
179-
beast; // beast is Winged
177+
beast; // Legged & Winged
180178
}
181179
}

tests/baselines/reference/typeGuardIntersectionTypes.symbols

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -176,15 +176,15 @@ function identifyBeast(beast: Beast) {
176176
>hasWings : Symbol(hasWings, Decl(typeGuardIntersectionTypes.ts, 61, 83))
177177
>beast : Symbol(beast, Decl(typeGuardIntersectionTypes.ts, 65, 23))
178178

179-
if (beast.legs === 4) { // ERROR TS2339: Property 'legs' does not exist on type 'Winged'.
179+
if (beast.legs === 4) {
180180
>beast.legs : Symbol(Legged.legs, Decl(typeGuardIntersectionTypes.ts, 57, 21))
181181
>beast : Symbol(beast, Decl(typeGuardIntersectionTypes.ts, 65, 23))
182182
>legs : Symbol(Legged.legs, Decl(typeGuardIntersectionTypes.ts, 57, 21))
183183

184184
log(`pegasus - 4 legs, wings`);
185185
>log : Symbol(log, Decl(typeGuardIntersectionTypes.ts, 49, 1))
186186
}
187-
else if (beast.legs === 2) { // ERROR TS2339...
187+
else if (beast.legs === 2) {
188188
>beast.legs : Symbol(Legged.legs, Decl(typeGuardIntersectionTypes.ts, 57, 21))
189189
>beast : Symbol(beast, Decl(typeGuardIntersectionTypes.ts, 65, 23))
190190
>legs : Symbol(Legged.legs, Decl(typeGuardIntersectionTypes.ts, 57, 21))
@@ -193,7 +193,7 @@ function identifyBeast(beast: Beast) {
193193
>log : Symbol(log, Decl(typeGuardIntersectionTypes.ts, 49, 1))
194194
}
195195
else {
196-
log(`unknown - ${beast.legs} legs, wings`); // ERROR TS2339...
196+
log(`unknown - ${beast.legs} legs, wings`);
197197
>log : Symbol(log, Decl(typeGuardIntersectionTypes.ts, 49, 1))
198198
>beast.legs : Symbol(Legged.legs, Decl(typeGuardIntersectionTypes.ts, 57, 21))
199199
>beast : Symbol(beast, Decl(typeGuardIntersectionTypes.ts, 65, 23))
@@ -238,13 +238,11 @@ function beastFoo(beast: Object) {
238238
>hasLegs : Symbol(hasLegs, Decl(typeGuardIntersectionTypes.ts, 58, 39))
239239
>beast : Symbol(beast, Decl(typeGuardIntersectionTypes.ts, 100, 18))
240240

241-
beast // beast is Legged
241+
beast; // Winged & Legged
242242
>beast : Symbol(beast, Decl(typeGuardIntersectionTypes.ts, 100, 18))
243-
244-
// ideally, beast would be Winged && Legged here...
245243
}
246244
else {
247-
beast
245+
beast;
248246
>beast : Symbol(beast, Decl(typeGuardIntersectionTypes.ts, 100, 18))
249247
}
250248

@@ -254,9 +252,7 @@ function beastFoo(beast: Object) {
254252
>hasWings : Symbol(hasWings, Decl(typeGuardIntersectionTypes.ts, 61, 83))
255253
>beast : Symbol(beast, Decl(typeGuardIntersectionTypes.ts, 100, 18))
256254

257-
beast // beast is Winged
255+
beast; // Legged & Winged
258256
>beast : Symbol(beast, Decl(typeGuardIntersectionTypes.ts, 100, 18))
259-
260-
// ideally, beast would be Legged && Winged here...
261257
}
262258
}

tests/baselines/reference/typeGuardIntersectionTypes.types

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ function identifyBeast(beast: Beast) {
201201
>hasWings : (x: Beast) => x is Winged
202202
>beast : Legged
203203

204-
if (beast.legs === 4) { // ERROR TS2339: Property 'legs' does not exist on type 'Winged'.
204+
if (beast.legs === 4) {
205205
>beast.legs === 4 : boolean
206206
>beast.legs : number
207207
>beast : Legged & Winged
@@ -213,7 +213,7 @@ function identifyBeast(beast: Beast) {
213213
>log : (s: string) => void
214214
>`pegasus - 4 legs, wings` : string
215215
}
216-
else if (beast.legs === 2) { // ERROR TS2339...
216+
else if (beast.legs === 2) {
217217
>beast.legs === 2 : boolean
218218
>beast.legs : number
219219
>beast : Legged & Winged
@@ -226,7 +226,7 @@ function identifyBeast(beast: Beast) {
226226
>`bird - 2 legs, wings` : string
227227
}
228228
else {
229-
log(`unknown - ${beast.legs} legs, wings`); // ERROR TS2339...
229+
log(`unknown - ${beast.legs} legs, wings`);
230230
>log(`unknown - ${beast.legs} legs, wings`) : void
231231
>log : (s: string) => void
232232
>`unknown - ${beast.legs} legs, wings` : string
@@ -283,13 +283,11 @@ function beastFoo(beast: Object) {
283283
>hasLegs : (x: Beast) => x is Legged
284284
>beast : Winged
285285

286-
beast // beast is Legged
286+
beast; // Winged & Legged
287287
>beast : Winged & Legged
288-
289-
// ideally, beast would be Winged && Legged here...
290288
}
291289
else {
292-
beast
290+
beast;
293291
>beast : Object
294292
}
295293

@@ -302,9 +300,7 @@ function beastFoo(beast: Object) {
302300
>hasWings : (x: Beast) => x is Winged
303301
>beast : Legged
304302

305-
beast // beast is Winged
303+
beast; // Legged & Winged
306304
>beast : Legged & Winged
307-
308-
// ideally, beast would be Legged && Winged here...
309305
}
310306
}

tests/cases/conformance/expressions/typeGuards/typeGuardIntersectionTypes.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,14 @@ function identifyBeast(beast: Beast) {
7171

7272
// All winged beasts with legs
7373
if (hasWings(beast)) {
74-
if (beast.legs === 4) { // ERROR TS2339: Property 'legs' does not exist on type 'Winged'.
74+
if (beast.legs === 4) {
7575
log(`pegasus - 4 legs, wings`);
7676
}
77-
else if (beast.legs === 2) { // ERROR TS2339...
77+
else if (beast.legs === 2) {
7878
log(`bird - 2 legs, wings`);
7979
}
8080
else {
81-
log(`unknown - ${beast.legs} legs, wings`); // ERROR TS2339...
81+
log(`unknown - ${beast.legs} legs, wings`);
8282
}
8383
}
8484

@@ -101,15 +101,13 @@ function identifyBeast(beast: Beast) {
101101

102102
function beastFoo(beast: Object) {
103103
if (hasWings(beast) && hasLegs(beast)) {
104-
beast // beast is Legged
105-
// ideally, beast would be Winged && Legged here...
104+
beast; // Winged & Legged
106105
}
107106
else {
108-
beast
107+
beast;
109108
}
110109

111110
if (hasLegs(beast) && hasWings(beast)) {
112-
beast // beast is Winged
113-
// ideally, beast would be Legged && Winged here...
111+
beast; // Legged & Winged
114112
}
115113
}

0 commit comments

Comments
 (0)