TypeScript/tests/baselines/reference/unionTypeLiterals.js
Sheetal Nandi 16fc7a22e2 Tests for union type literals
A union type literal is written as a sequence of types separated by vertical bars.
UnionType:
PrimaryOrUnionType   |   PrimaryType
A union typle literal references a union type.
When function or constructor types are included in union types they must be enclosed in parentheses
2014-11-04 13:18:47 -08:00

30 lines
905 B
TypeScript

//// [unionTypeLiterals.ts]
// basic valid forms of union literals
var simpleUnion: string | number;
var unionOfUnion: string | number | boolean;
var arrayOfUnions: (string | number)[];
var arrayOfUnions: Array<string | number>;
var unionOfFunctionType: (() => string) | (() => number);
var unionOfFunctionType: { (): string } | { (): number };
var unionOfFunctionType: () => string | number;
var unionOfConstructorType: (new () => string) | (new () => number);
var unionOfConstructorType: { new (): string } | { new (): number };
var unionOfConstructorType: new () => string | number;
//// [unionTypeLiterals.js]
// basic valid forms of union literals
var simpleUnion;
var unionOfUnion;
var arrayOfUnions;
var arrayOfUnions;
var unionOfFunctionType;
var unionOfFunctionType;
var unionOfFunctionType;
var unionOfConstructorType;
var unionOfConstructorType;
var unionOfConstructorType;