elastic/kibana

[saved objects] Improve type safety in the saved objects repository

开放

#239,468 创建于 2025年10月17日

 (4 条评论) (0 个反应) (1 位负责人)TypeScript (8,021 个派生)batch import
Feature:Saved ObjectsTeam:Coregood first issue💝community

仓库指标

星标
 (19,065 个星标)
PR 合并指标
 (PR 指标待抓取)

描述

The is an existing pattern of using // @ts-expect-error MultiGetHit._source is optional comments in the saved object repository code that weakens the type safety. We should use a type guard instead

/**
 * Type guard to check if an item is a GetGetResult.
 */
export function isGetGetResult<TDocument = unknown>(
  item: MgetResponseItem<TDocument>
): item is GetGetResult<TDocument> {
  return (item as MgetMultiGetError).error === undefined;
}

Originally posted by @rudolf in https://github.com/elastic/kibana/pull/224411#discussion_r2348988329

贡献者指南