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