|
| 1 | +=== tests/cases/compiler/narrowTypeByInstanceof.ts === |
| 2 | + class Match { |
| 3 | +>Match : Symbol(Match, Decl(narrowTypeByInstanceof.ts, 0, 0)) |
| 4 | + |
| 5 | + public range(): any { |
| 6 | +>range : Symbol(range, Decl(narrowTypeByInstanceof.ts, 0, 17)) |
| 7 | + |
| 8 | + return undefined; |
| 9 | +>undefined : Symbol(undefined) |
| 10 | + } |
| 11 | + } |
| 12 | + |
| 13 | + class FileMatch { |
| 14 | +>FileMatch : Symbol(FileMatch, Decl(narrowTypeByInstanceof.ts, 4, 5)) |
| 15 | + |
| 16 | + public resource(): any { |
| 17 | +>resource : Symbol(resource, Decl(narrowTypeByInstanceof.ts, 6, 21)) |
| 18 | + |
| 19 | + return undefined; |
| 20 | +>undefined : Symbol(undefined) |
| 21 | + } |
| 22 | + } |
| 23 | + |
| 24 | +type FileMatchOrMatch = FileMatch | Match; |
| 25 | +>FileMatchOrMatch : Symbol(FileMatchOrMatch, Decl(narrowTypeByInstanceof.ts, 10, 5)) |
| 26 | +>FileMatch : Symbol(FileMatch, Decl(narrowTypeByInstanceof.ts, 4, 5)) |
| 27 | +>Match : Symbol(Match, Decl(narrowTypeByInstanceof.ts, 0, 0)) |
| 28 | + |
| 29 | + |
| 30 | +let elementA: FileMatchOrMatch, elementB: FileMatchOrMatch; |
| 31 | +>elementA : Symbol(elementA, Decl(narrowTypeByInstanceof.ts, 15, 3)) |
| 32 | +>FileMatchOrMatch : Symbol(FileMatchOrMatch, Decl(narrowTypeByInstanceof.ts, 10, 5)) |
| 33 | +>elementB : Symbol(elementB, Decl(narrowTypeByInstanceof.ts, 15, 31)) |
| 34 | +>FileMatchOrMatch : Symbol(FileMatchOrMatch, Decl(narrowTypeByInstanceof.ts, 10, 5)) |
| 35 | + |
| 36 | +if (elementA instanceof FileMatch && elementB instanceof FileMatch) { |
| 37 | +>elementA : Symbol(elementA, Decl(narrowTypeByInstanceof.ts, 15, 3)) |
| 38 | +>FileMatch : Symbol(FileMatch, Decl(narrowTypeByInstanceof.ts, 4, 5)) |
| 39 | +>elementB : Symbol(elementB, Decl(narrowTypeByInstanceof.ts, 15, 31)) |
| 40 | +>FileMatch : Symbol(FileMatch, Decl(narrowTypeByInstanceof.ts, 4, 5)) |
| 41 | + |
| 42 | + let a = elementA.resource().path; |
| 43 | +>a : Symbol(a, Decl(narrowTypeByInstanceof.ts, 18, 7)) |
| 44 | +>elementA.resource : Symbol(FileMatch.resource, Decl(narrowTypeByInstanceof.ts, 6, 21)) |
| 45 | +>elementA : Symbol(elementA, Decl(narrowTypeByInstanceof.ts, 15, 3)) |
| 46 | +>resource : Symbol(FileMatch.resource, Decl(narrowTypeByInstanceof.ts, 6, 21)) |
| 47 | + |
| 48 | + let b = elementB.resource().path; |
| 49 | +>b : Symbol(b, Decl(narrowTypeByInstanceof.ts, 19, 7)) |
| 50 | +>elementB.resource : Symbol(FileMatch.resource, Decl(narrowTypeByInstanceof.ts, 6, 21)) |
| 51 | +>elementB : Symbol(elementB, Decl(narrowTypeByInstanceof.ts, 15, 31)) |
| 52 | +>resource : Symbol(FileMatch.resource, Decl(narrowTypeByInstanceof.ts, 6, 21)) |
| 53 | + |
| 54 | +} else if (elementA instanceof Match && elementB instanceof Match) { |
| 55 | +>elementA : Symbol(elementA, Decl(narrowTypeByInstanceof.ts, 15, 3)) |
| 56 | +>Match : Symbol(Match, Decl(narrowTypeByInstanceof.ts, 0, 0)) |
| 57 | +>elementB : Symbol(elementB, Decl(narrowTypeByInstanceof.ts, 15, 31)) |
| 58 | +>Match : Symbol(Match, Decl(narrowTypeByInstanceof.ts, 0, 0)) |
| 59 | + |
| 60 | + let a = elementA.range(); |
| 61 | +>a : Symbol(a, Decl(narrowTypeByInstanceof.ts, 21, 7)) |
| 62 | +>elementA.range : Symbol(Match.range, Decl(narrowTypeByInstanceof.ts, 0, 17)) |
| 63 | +>elementA : Symbol(elementA, Decl(narrowTypeByInstanceof.ts, 15, 3)) |
| 64 | +>range : Symbol(Match.range, Decl(narrowTypeByInstanceof.ts, 0, 17)) |
| 65 | + |
| 66 | + let b = elementB.range(); |
| 67 | +>b : Symbol(b, Decl(narrowTypeByInstanceof.ts, 22, 7)) |
| 68 | +>elementB.range : Symbol(Match.range, Decl(narrowTypeByInstanceof.ts, 0, 17)) |
| 69 | +>elementB : Symbol(elementB, Decl(narrowTypeByInstanceof.ts, 15, 31)) |
| 70 | +>range : Symbol(Match.range, Decl(narrowTypeByInstanceof.ts, 0, 17)) |
| 71 | +} |
| 72 | + |
0 commit comments