首页 > 解决方案 > Getting size information on object with index signature

问题描述

I have a Typescript class with an index signature, like so:

[index: number]: {
   start: number;
   length: number;
}

I would like to get information on the number of items it holds. I haven't found a good way to do so, because using Object.keys(myObject).length to get the length works, but is very error prone, because the day I add a member to my class, that value becomes wrong.

标签: typescript

解决方案


推荐阅读