TypeScript/tests/cases/compiler/indexSignaturesInferentialTyping.ts
Nathan Shively-Sanders 5138e8be8e Correct tests and update baselines.
A lot of tests used non-numeric property names for object literals that
are contextually typed only by a numeric indexer.
2016-05-25 11:37:10 -07:00

7 lines
303 B
TypeScript

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 = bar({ 0: 0, 1: 1 });
var x3 = bar({ zero: 0, one: 1 }); // type should be number