68 lines
1.4 KiB
Text
68 lines
1.4 KiB
Text
=== tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObjectTypeArgsAndIndexers.ts ===
|
|
// Type inference infers from indexers in target type, no errors expected
|
|
|
|
function foo<T>(x: T) {
|
|
>foo : <T>(x: T) => T
|
|
>T : T
|
|
>x : T
|
|
>T : T
|
|
|
|
return x;
|
|
>x : T
|
|
}
|
|
|
|
var a: {
|
|
>a : { [x: string]: Object; [x: number]: Date; }
|
|
|
|
[x: string]: Object;
|
|
>x : string
|
|
>Object : Object
|
|
|
|
[x: number]: Date;
|
|
>x : number
|
|
>Date : Date
|
|
|
|
};
|
|
var r = foo(a);
|
|
>r : { [x: string]: Object; [x: number]: Date; }
|
|
>foo(a) : { [x: string]: Object; [x: number]: Date; }
|
|
>foo : <T>(x: T) => T
|
|
>a : { [x: string]: Object; [x: number]: Date; }
|
|
|
|
function other<T extends Date>(arg: T) {
|
|
>other : <T extends Date>(arg: T) => void
|
|
>T : T
|
|
>Date : Date
|
|
>arg : T
|
|
>T : T
|
|
|
|
var b: {
|
|
>b : { [x: string]: Object; [x: number]: T; }
|
|
|
|
[x: string]: Object;
|
|
>x : string
|
|
>Object : Object
|
|
|
|
[x: number]: T
|
|
>x : number
|
|
>T : T
|
|
|
|
};
|
|
var r2 = foo(b);
|
|
>r2 : { [x: string]: Object; [x: number]: T; }
|
|
>foo(b) : { [x: string]: Object; [x: number]: T; }
|
|
>foo : <T>(x: T) => T
|
|
>b : { [x: string]: Object; [x: number]: T; }
|
|
|
|
var d = r2[1];
|
|
>d : T
|
|
>r2[1] : T
|
|
>r2 : { [x: string]: Object; [x: number]: T; }
|
|
>1 : number
|
|
|
|
var e = r2['1'];
|
|
>e : Object
|
|
>r2['1'] : Object
|
|
>r2 : { [x: string]: Object; [x: number]: T; }
|
|
>'1' : string
|
|
}
|