typescript - 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.
解决方案
推荐阅读
- amazon-web-services - 是否可以忽略 AWS lambda 中的异常以添加到“错误”指标中?
- javascript - puppeteer 导航指标:每个请求/响应的开始和结束时间
- bash - 针对 ARG_MAX 和目录中文件数的 IF 测试
- java - 设计一个用户命令和多个输入
- azure-pipelines - 构建定义中的访问被拒绝错误。服务器重启后构建成功
- python - 根据范围映射数据框中的值
- c# - 在使用 Entity Framework Core 进行表设计时需要帮助
- c# - 将网页添加到 gRPC 服务项目(VS 2019)
- jenkins - kubernetes jenkins 插件不会创建 2 个容器
- python - 添加颜色对应于现有绘图中不同线条的颜色条