Skip to content

javascript: certain types aren't generic #853

Open
@Haroenv

Description

@Haroenv

Description

  • SearchResponse, SearchResponses should take a single generic THit
  • HighlightResult and SnippetResults should take a single generic THit

SnippetResults and HighlightResult should also be recursive as in v4

declare type SnippetMatch = {
    readonly value: string;
    readonly matchLevel: 'none' | 'partial' | 'full';
};

export declare type SnippetResult<THit> = THit extends string | number ? SnippetMatch : {
    [KAttribute in keyof THit]: SnippetResult<THit[KAttribute]>;
};


declare type HighlightMatch = {
    readonly value: string;
    readonly matchLevel: 'none' | 'partial' | 'full';
    readonly matchedWords: readonly string[];
    readonly fullyHighlighted?: boolean;
};

export declare type HighlightResult<THit> = THit extends string | number ? HighlightMatch : {
    [KAttribute in keyof THit]?: HighlightResult<THit[KAttribute]>;
};

export declare type Hit<THit> = THit & {
    readonly objectID: string;
    readonly _highlightResult?: HighlightResult<THit>;
    readonly _snippetResult?: SnippetResult<THit>;
    readonly _rankingInfo?: RankingInfo;
    readonly _distinctSeqID?: number;
};

Metadata

Metadata

Assignees

No one assigned

    Labels

    JavaIssue related to the Java clientJavaScriptIssue related to the JavaScript client

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions