1interface A { a: string } 2interface B { b: string } 3interface C { c: string } 4interface D { d: string } 5 6// Identical ways of writing the same type 7type X1 = (A | B) & (C | D); 8type X2 = A & (C | D) | B & (C | D) 9type X3 = A & C | A & D | B & C | B & D; 10 11var x: X1; 12var x: X2; 13var x: X3; 14 15interface X { x: string } 16interface Y { y: string } 17 18// Identical ways of writing the same type 19type Y1 = (A | X & Y) & (C | D); 20type Y2 = A & (C | D) | X & Y & (C | D) 21type Y3 = A & C | A & D | X & Y & C | X & Y & D; 22 23var y: Y1; 24var y: Y2; 25var y: Y3; 26 27interface M { m: string } 28interface N { n: string } 29 30// Identical ways of writing the same type 31type Z1 = (A | X & (M | N)) & (C | D); 32type Z2 = A & (C | D) | X & (M | N) & (C | D) 33type Z3 = A & C | A & D | X & (M | N) & C | X & (M | N) & D; 34type Z4 = A & C | A & D | X & M & C | X & N & C | X & M & D | X & N & D; 35 36var z: Z1; 37var z: Z2; 38var z: Z3; 39var z: Z4; 40 41// Repro from #9919 42 43type ToString = { 44 toString(): string; 45} 46 47type BoxedValue = { kind: 'int', num: number } 48 | { kind: 'string', str: string } 49 50type IntersectionFail = BoxedValue & ToString 51 52type IntersectionInline = { kind: 'int', num: number } & ToString 53 | { kind: 'string', str: string } & ToString 54 55function getValueAsString(value: IntersectionFail): string { 56 if (value.kind === 'int') { 57 return '' + value.num; 58 } 59 return value.str; 60} 61 62// Repro from #12535 63 64namespace enums { 65 export const enum A { 66 a1, 67 a2, 68 a3, 69 // ... elements omitted for the sake of clarity 70 a75, 71 a76, 72 a77, 73 } 74 export const enum B { 75 b1, 76 b2, 77 // ... elements omitted for the sake of clarity 78 b86, 79 b87, 80 } 81 export const enum C { 82 c1, 83 c2, 84 // ... elements omitted for the sake of clarity 85 c210, 86 c211, 87 } 88 export type Genre = A | B | C; 89} 90 91type Foo = { 92 genreId: enums.Genre; 93}; 94 95type Bar = { 96 genreId: enums.Genre; 97}; 98 99type FooBar = Foo & Bar; 100 101function foo(so: any) { 102 const val = so as FooBar; 103 const isGenre = val.genreId; 104 return isGenre; 105}