2014-11-03 22:36:06 +01:00
|
|
|
=== tests/cases/conformance/types/union/unionTypeIndexSignature.ts ===
|
|
|
|
var numOrDate: number | Date;
|
|
|
|
>numOrDate : number | Date
|
|
|
|
>Date : Date
|
|
|
|
|
|
|
|
var anyVar: number;
|
|
|
|
>anyVar : number
|
|
|
|
|
|
|
|
// If each type in U has a string index signature,
|
|
|
|
// U has a string index signature of a union type of the types of the string index signatures from each type in U.
|
|
|
|
|
|
|
|
var unionOfDifferentReturnType: { [a: string]: number; } | { [a: string]: Date; };
|
2014-12-06 01:58:49 +01:00
|
|
|
>unionOfDifferentReturnType : { [a: string]: number; } | { [a: string]: Date; }
|
2014-11-03 22:36:06 +01:00
|
|
|
>a : string
|
|
|
|
>a : string
|
|
|
|
>Date : Date
|
|
|
|
|
|
|
|
numOrDate = unionOfDifferentReturnType["hello"]; // number | Date
|
|
|
|
>numOrDate = unionOfDifferentReturnType["hello"] : number | Date
|
|
|
|
>numOrDate : number | Date
|
|
|
|
>unionOfDifferentReturnType["hello"] : number | Date
|
2014-12-06 01:58:49 +01:00
|
|
|
>unionOfDifferentReturnType : { [a: string]: number; } | { [a: string]: Date; }
|
2014-11-03 22:36:06 +01:00
|
|
|
|
|
|
|
numOrDate = unionOfDifferentReturnType[10]; // number | Date
|
|
|
|
>numOrDate = unionOfDifferentReturnType[10] : number | Date
|
|
|
|
>numOrDate : number | Date
|
|
|
|
>unionOfDifferentReturnType[10] : number | Date
|
2014-12-06 01:58:49 +01:00
|
|
|
>unionOfDifferentReturnType : { [a: string]: number; } | { [a: string]: Date; }
|
2014-11-03 22:36:06 +01:00
|
|
|
|
|
|
|
var unionOfTypesWithAndWithoutStringSignature: { [a: string]: number; } | boolean;
|
2014-12-06 01:58:49 +01:00
|
|
|
>unionOfTypesWithAndWithoutStringSignature : boolean | { [a: string]: number; }
|
2014-11-03 22:36:06 +01:00
|
|
|
>a : string
|
|
|
|
|
|
|
|
anyVar = unionOfTypesWithAndWithoutStringSignature["hello"]; // any
|
|
|
|
>anyVar = unionOfTypesWithAndWithoutStringSignature["hello"] : any
|
|
|
|
>anyVar : number
|
|
|
|
>unionOfTypesWithAndWithoutStringSignature["hello"] : any
|
2014-12-06 01:58:49 +01:00
|
|
|
>unionOfTypesWithAndWithoutStringSignature : boolean | { [a: string]: number; }
|
2014-11-03 22:36:06 +01:00
|
|
|
|
|
|
|
anyVar = unionOfTypesWithAndWithoutStringSignature[10]; // any
|
|
|
|
>anyVar = unionOfTypesWithAndWithoutStringSignature[10] : any
|
|
|
|
>anyVar : number
|
|
|
|
>unionOfTypesWithAndWithoutStringSignature[10] : any
|
2014-12-06 01:58:49 +01:00
|
|
|
>unionOfTypesWithAndWithoutStringSignature : boolean | { [a: string]: number; }
|
2014-11-03 22:36:06 +01:00
|
|
|
|
|
|
|
// If each type in U has a numeric index signature,
|
|
|
|
// U has a numeric index signature of a union type of the types of the numeric index signatures from each type in U.
|
|
|
|
var unionOfDifferentReturnType1: { [a: number]: number; } | { [a: number]: Date; };
|
2014-12-06 01:58:49 +01:00
|
|
|
>unionOfDifferentReturnType1 : { [a: number]: number; } | { [a: number]: Date; }
|
2014-11-03 22:36:06 +01:00
|
|
|
>a : number
|
|
|
|
>a : number
|
|
|
|
>Date : Date
|
|
|
|
|
|
|
|
numOrDate = unionOfDifferentReturnType1["hello"]; // any
|
|
|
|
>numOrDate = unionOfDifferentReturnType1["hello"] : any
|
|
|
|
>numOrDate : number | Date
|
|
|
|
>unionOfDifferentReturnType1["hello"] : any
|
2014-12-06 01:58:49 +01:00
|
|
|
>unionOfDifferentReturnType1 : { [a: number]: number; } | { [a: number]: Date; }
|
2014-11-03 22:36:06 +01:00
|
|
|
|
|
|
|
numOrDate = unionOfDifferentReturnType1[10]; // number | Date
|
|
|
|
>numOrDate = unionOfDifferentReturnType1[10] : number | Date
|
|
|
|
>numOrDate : number | Date
|
|
|
|
>unionOfDifferentReturnType1[10] : number | Date
|
2014-12-06 01:58:49 +01:00
|
|
|
>unionOfDifferentReturnType1 : { [a: number]: number; } | { [a: number]: Date; }
|
2014-11-03 22:36:06 +01:00
|
|
|
|
|
|
|
var unionOfTypesWithAndWithoutStringSignature1: { [a: number]: number; } | boolean;
|
2014-12-06 01:58:49 +01:00
|
|
|
>unionOfTypesWithAndWithoutStringSignature1 : boolean | { [a: number]: number; }
|
2014-11-03 22:36:06 +01:00
|
|
|
>a : number
|
|
|
|
|
|
|
|
anyVar = unionOfTypesWithAndWithoutStringSignature1["hello"]; // any
|
|
|
|
>anyVar = unionOfTypesWithAndWithoutStringSignature1["hello"] : any
|
|
|
|
>anyVar : number
|
|
|
|
>unionOfTypesWithAndWithoutStringSignature1["hello"] : any
|
2014-12-06 01:58:49 +01:00
|
|
|
>unionOfTypesWithAndWithoutStringSignature1 : boolean | { [a: number]: number; }
|
2014-11-03 22:36:06 +01:00
|
|
|
|
|
|
|
anyVar = unionOfTypesWithAndWithoutStringSignature1[10]; // any
|
|
|
|
>anyVar = unionOfTypesWithAndWithoutStringSignature1[10] : any
|
|
|
|
>anyVar : number
|
|
|
|
>unionOfTypesWithAndWithoutStringSignature1[10] : any
|
2014-12-06 01:58:49 +01:00
|
|
|
>unionOfTypesWithAndWithoutStringSignature1 : boolean | { [a: number]: number; }
|
2014-11-03 22:36:06 +01:00
|
|
|
|