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

貢獻者指南