2014-08-15 23:33:16 +02:00
|
|
|
=== tests/cases/compiler/indexSignaturesInferentialTyping.ts ===
|
|
|
|
function foo<T>(items: { [index: number]: T }): T { return undefined; }
|
2014-12-06 01:58:49 +01:00
|
|
|
>foo : <T>(items: { [index: number]: T; }) => T
|
2014-08-15 23:33:16 +02:00
|
|
|
>T : T
|
2014-12-06 01:58:49 +01:00
|
|
|
>items : { [index: number]: T; }
|
2014-08-15 23:33:16 +02:00
|
|
|
>index : number
|
|
|
|
>T : T
|
|
|
|
>T : T
|
|
|
|
>undefined : undefined
|
|
|
|
|
|
|
|
function bar<T>(items: { [index: string]: T }): T { return undefined; }
|
2014-12-06 01:58:49 +01:00
|
|
|
>bar : <T>(items: { [index: string]: T; }) => T
|
2014-08-15 23:33:16 +02:00
|
|
|
>T : T
|
2014-12-06 01:58:49 +01:00
|
|
|
>items : { [index: string]: T; }
|
2014-08-15 23:33:16 +02:00
|
|
|
>index : string
|
|
|
|
>T : T
|
|
|
|
>T : T
|
|
|
|
>undefined : undefined
|
|
|
|
|
|
|
|
var x1 = foo({ 0: 0, 1: 1 }); // type should be number
|
|
|
|
>x1 : number
|
|
|
|
>foo({ 0: 0, 1: 1 }) : number
|
2014-12-06 01:58:49 +01:00
|
|
|
>foo : <T>(items: { [index: number]: T; }) => T
|
2014-08-15 23:33:16 +02:00
|
|
|
>{ 0: 0, 1: 1 } : { [x: number]: number; 0: number; 1: number; }
|
|
|
|
|
|
|
|
var x2 = foo({ zero: 0, one: 1 });
|
2014-10-13 15:56:58 +02:00
|
|
|
>x2 : any
|
|
|
|
>foo({ zero: 0, one: 1 }) : any
|
2014-12-06 01:58:49 +01:00
|
|
|
>foo : <T>(items: { [index: number]: T; }) => T
|
2014-10-13 15:56:58 +02:00
|
|
|
>{ zero: 0, one: 1 } : { [x: number]: undefined; zero: number; one: number; }
|
2014-08-15 23:33:16 +02:00
|
|
|
>zero : number
|
|
|
|
>one : number
|
|
|
|
|
|
|
|
var x3 = bar({ 0: 0, 1: 1 });
|
|
|
|
>x3 : number
|
|
|
|
>bar({ 0: 0, 1: 1 }) : number
|
2014-12-06 01:58:49 +01:00
|
|
|
>bar : <T>(items: { [index: string]: T; }) => T
|
2014-08-15 23:33:16 +02:00
|
|
|
>{ 0: 0, 1: 1 } : { [x: string]: number; 0: number; 1: number; }
|
|
|
|
|
|
|
|
var x4 = bar({ zero: 0, one: 1 }); // type should be number
|
|
|
|
>x4 : number
|
|
|
|
>bar({ zero: 0, one: 1 }) : number
|
2014-12-06 01:58:49 +01:00
|
|
|
>bar : <T>(items: { [index: string]: T; }) => T
|
2014-08-15 23:33:16 +02:00
|
|
|
>{ zero: 0, one: 1 } : { [x: string]: number; zero: number; one: number; }
|
|
|
|
>zero : number
|
|
|
|
>one : number
|
|
|
|
|