Skip to content
This repository has been archived by the owner on Jul 11, 2023. It is now read-only.

feat(typing): Update SearchResults hits, expose optional hit typings #914

Merged
merged 4 commits into from
Aug 2, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import EventEmitter from '@algolia/events';
import {
FindAnswersResponse,
HighlightResult,
RankingInfo,
SearchClient,
SearchOptions,
SearchResponse,
SnippetResult,
} from './types/algoliasearch';

/**
Expand Down Expand Up @@ -1147,6 +1150,10 @@ declare namespace algoliasearchHelper {
*/
hits: (T & {
readonly objectID: string;
readonly _highlightResult?: HighlightResult<T>;
readonly _snippetResult?: SnippetResult<T>;
readonly _rankingInfo?: RankingInfo;
readonly _distinctSeqID?: number;
})[];
/**
* index where the results come from
Expand Down
4 changes: 4 additions & 0 deletions types/algoliasearch.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ type DefaultSearchClient = PickForClient<{
v5: ClientV5;
}>;

export type HighlightResult<T> = ClientSearch.HighlightResult<T>;
export type SnippetResult<T> = ClientSearch.SnippetResult<T>;
export type RankingInfo = ClientSearch.RankingInfo;
cdhawke marked this conversation as resolved.
Show resolved Hide resolved

export type SearchOptions = PickForClient<{
// @ts-ignore
v3: AlgoliaSearch.QueryParameters;
Expand Down