TypeScript/tests/cases/conformance/types/union/unionTypeEquivalence.ts
Sheetal Nandi 357bd87612 Tests for union members:
If each type in U has a property P, U has a property P of a union type of the types of P from each type in U.
2014-11-04 13:18:27 -08:00

18 lines
514 B
TypeScript

// A | B is equivalent to A if B is a subtype of A
class C { }
class D extends C { foo() { } }
var x: C;
var x : C | D;
// A | B is equivalent to B | A.
var y: string | number;
var y : number | string;
// AB | C is equivalent to A | BC, where AB is A | B and BC is B | C.
var z : string | number | boolean;
var z : (string | number) | boolean;
var z : string | (number | boolean);
var AB : string | number;
var BC : number | boolean;
var z1: typeof AB | boolean;
var z1: string | typeof BC;