Skip to content

Commit

Permalink
Merge pull request #258 from tharropoulos/string-unions
Browse files Browse the repository at this point in the history
fix(types): improve type safety for query params
  • Loading branch information
jasonbosco authored Jan 23, 2025
2 parents 1939f03 + 0531afb commit a81a0a9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/Typesense/Documents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ export const arrayableParams: ArraybleParams = {

export interface SearchParams {
// From https://typesense.org/docs/latest/api/documents.html#arguments
q?: string;
// eslint-disable-next-line @typescript-eslint/ban-types -- Can't use `object` here, it needs to intersect with `{}`
q?: "*" | (string & {});
query_by?: string | string[];
query_by_weights?: string | number[];
prefix?: string | boolean | boolean[]; // default: true
Expand Down
5 changes: 3 additions & 2 deletions src/Typesense/Operations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ export default class Operations {
constructor(private apiCall: ApiCall) {}

async perform(
operationName: "vote" | "snapshot" | "cache/clear" | string,
queryParameters: Record<string, any> = {}
// eslint-disable-next-line @typescript-eslint/ban-types -- Can't use `object` here, it needs to intersect with `{}`
operationName: "vote" | "snapshot" | "cache/clear" | (string & {}),
queryParameters: Record<string, any> = {},
): Promise<any> {
return this.apiCall.post(
`${RESOURCEPATH}/${operationName}`,
Expand Down

0 comments on commit a81a0a9

Please sign in to comment.