ts-object-path icon indicating copy to clipboard operation
ts-object-path copied to clipboard

Bug report: There is no type checking on arrays.

Open samal-rasmussen opened this issue 6 years ago • 0 comments

Take this example from the tests:

it('Works with arrays', () => {
  const o: ITest = { one: 5, four: [null, { firrst: 4 }] };
  expect(get<ITest, number>(o, (p) => p.four[0].firrst)).toBeUndefined();
  expect(get<ITest, number>(o, (p) => p.four[1].firrst)).toEqual(4);
});

Expected: The type of the element returned from the indexed access on the four array is null | {firrst: number}.

Actual: It is any

samal-rasmussen avatar Mar 23 '18 14:03 samal-rasmussen