2014-07-13 01:04:16 +02:00
|
|
|
//// [indexSignaturesInferentialTyping.ts]
|
|
|
|
function foo<T>(items: { [index: number]: T }): T { return undefined; }
|
|
|
|
function bar<T>(items: { [index: string]: T }): T { return undefined; }
|
|
|
|
|
|
|
|
var x1 = foo({ 0: 0, 1: 1 }); // type should be number
|
|
|
|
var x2 = foo({ zero: 0, one: 1 });
|
|
|
|
var x3 = bar({ 0: 0, 1: 1 });
|
|
|
|
var x4 = bar({ zero: 0, one: 1 }); // type should be number
|
|
|
|
|
|
|
|
|
|
|
|
//// [indexSignaturesInferentialTyping.js]
|
2015-02-07 05:03:24 +01:00
|
|
|
function foo(items) { return undefined; }
|
|
|
|
function bar(items) { return undefined; }
|
2014-08-15 22:18:54 +02:00
|
|
|
var x1 = foo({ 0: 0, 1: 1 }); // type should be number
|
2014-07-13 01:04:16 +02:00
|
|
|
var x2 = foo({ zero: 0, one: 1 });
|
|
|
|
var x3 = bar({ 0: 0, 1: 1 });
|
2014-08-15 22:18:54 +02:00
|
|
|
var x4 = bar({ zero: 0, one: 1 }); // type should be number
|