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
|
=== tests/cases/conformance/types/union/unionTypeIndexSignature.ts ===
var numOrDate: number | Date;
>numOrDate : Symbol(numOrDate, Decl(unionTypeIndexSignature.ts, 0, 3))
>Date : Symbol(Date, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.scripthost.d.ts, --, --))
var anyVar: number;
>anyVar : Symbol(anyVar, Decl(unionTypeIndexSignature.ts, 1, 3))
// 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; };
>unionOfDifferentReturnType : Symbol(unionOfDifferentReturnType, Decl(unionTypeIndexSignature.ts, 6, 3))
>a : Symbol(a, Decl(unionTypeIndexSignature.ts, 6, 35))
>a : Symbol(a, Decl(unionTypeIndexSignature.ts, 6, 62))
>Date : Symbol(Date, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.scripthost.d.ts, --, --))
numOrDate = unionOfDifferentReturnType["hello"]; // number | Date
>numOrDate : Symbol(numOrDate, Decl(unionTypeIndexSignature.ts, 0, 3))
>unionOfDifferentReturnType : Symbol(unionOfDifferentReturnType, Decl(unionTypeIndexSignature.ts, 6, 3))
numOrDate = unionOfDifferentReturnType[10]; // number | Date
>numOrDate : Symbol(numOrDate, Decl(unionTypeIndexSignature.ts, 0, 3))
>unionOfDifferentReturnType : Symbol(unionOfDifferentReturnType, Decl(unionTypeIndexSignature.ts, 6, 3))
var unionOfTypesWithAndWithoutStringSignature: { [a: string]: number; } | boolean;
>unionOfTypesWithAndWithoutStringSignature : Symbol(unionOfTypesWithAndWithoutStringSignature, Decl(unionTypeIndexSignature.ts, 10, 3))
>a : Symbol(a, Decl(unionTypeIndexSignature.ts, 10, 50))
anyVar = unionOfTypesWithAndWithoutStringSignature["hello"]; // any
>anyVar : Symbol(anyVar, Decl(unionTypeIndexSignature.ts, 1, 3))
>unionOfTypesWithAndWithoutStringSignature : Symbol(unionOfTypesWithAndWithoutStringSignature, Decl(unionTypeIndexSignature.ts, 10, 3))
anyVar = unionOfTypesWithAndWithoutStringSignature[10]; // any
>anyVar : Symbol(anyVar, Decl(unionTypeIndexSignature.ts, 1, 3))
>unionOfTypesWithAndWithoutStringSignature : Symbol(unionOfTypesWithAndWithoutStringSignature, Decl(unionTypeIndexSignature.ts, 10, 3))
// 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; };
>unionOfDifferentReturnType1 : Symbol(unionOfDifferentReturnType1, Decl(unionTypeIndexSignature.ts, 16, 3))
>a : Symbol(a, Decl(unionTypeIndexSignature.ts, 16, 36))
>a : Symbol(a, Decl(unionTypeIndexSignature.ts, 16, 63))
>Date : Symbol(Date, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.scripthost.d.ts, --, --))
numOrDate = unionOfDifferentReturnType1["hello"]; // any
>numOrDate : Symbol(numOrDate, Decl(unionTypeIndexSignature.ts, 0, 3))
>unionOfDifferentReturnType1 : Symbol(unionOfDifferentReturnType1, Decl(unionTypeIndexSignature.ts, 16, 3))
numOrDate = unionOfDifferentReturnType1[10]; // number | Date
>numOrDate : Symbol(numOrDate, Decl(unionTypeIndexSignature.ts, 0, 3))
>unionOfDifferentReturnType1 : Symbol(unionOfDifferentReturnType1, Decl(unionTypeIndexSignature.ts, 16, 3))
var unionOfTypesWithAndWithoutStringSignature1: { [a: number]: number; } | boolean;
>unionOfTypesWithAndWithoutStringSignature1 : Symbol(unionOfTypesWithAndWithoutStringSignature1, Decl(unionTypeIndexSignature.ts, 20, 3))
>a : Symbol(a, Decl(unionTypeIndexSignature.ts, 20, 51))
anyVar = unionOfTypesWithAndWithoutStringSignature1["hello"]; // any
>anyVar : Symbol(anyVar, Decl(unionTypeIndexSignature.ts, 1, 3))
>unionOfTypesWithAndWithoutStringSignature1 : Symbol(unionOfTypesWithAndWithoutStringSignature1, Decl(unionTypeIndexSignature.ts, 20, 3))
anyVar = unionOfTypesWithAndWithoutStringSignature1[10]; // any
>anyVar : Symbol(anyVar, Decl(unionTypeIndexSignature.ts, 1, 3))
>unionOfTypesWithAndWithoutStringSignature1 : Symbol(unionOfTypesWithAndWithoutStringSignature1, Decl(unionTypeIndexSignature.ts, 20, 3))
|