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
|
=== tests/cases/compiler/unionPropertyExistence.ts ===
interface A {
inAll: string;
>inAll : string
notInB: string;
>notInB : string
notInC: string;
>notInC : string
}
interface B {
inAll: boolean;
>inAll : boolean
onlyInB: number;
>onlyInB : number
notInC: string;
>notInC : string
}
interface C {
inAll: number;
>inAll : number
notInB: string;
>notInB : string
}
type AB = A | B;
>AB : AB
type ABC = C | AB;
>ABC : ABC
var ab: AB;
>ab : AB
var abc: ABC;
>abc : ABC
declare const x: "foo" | "bar";
>x : "foo" | "bar"
declare const bFoo: B | "foo";
>bFoo : B | "foo"
x.nope();
>x.nope() : any
>x.nope : any
>x : "foo" | "bar"
>nope : any
bFoo.onlyInB;
>bFoo.onlyInB : any
>bFoo : B | "foo"
>onlyInB : any
x.length; // Ok
>x.length : number
>x : "foo" | "bar"
>length : number
bFoo.length;
>bFoo.length : any
>bFoo : B | "foo"
>length : any
ab.onlyInB;
>ab.onlyInB : any
>ab : AB
>onlyInB : any
ab.notInC; // Ok
>ab.notInC : string
>ab : AB
>notInC : string
abc.notInC;
>abc.notInC : any
>abc : ABC
>notInC : any
ab.notInB;
>ab.notInB : any
>ab : AB
>notInB : any
abc.notInB;
>abc.notInB : any
>abc : ABC
>notInB : any
abc.inAll; // Ok
>abc.inAll : string | number | boolean
>abc : ABC
>inAll : string | number | boolean
abc.inNone;
>abc.inNone : any
>abc : ABC
>inNone : any
|