question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Use the powerful typing from typescript for SearchResponse

See original GitHub issue

Hey! In the Go library there are no generics so I am a bit blocked to make a suitable return for the response to the hit.

TypeScript has a strong typing system and you should use it.

An exemple with the SearchResponse :

export interface SearchResponse<T> {
  hits: Hit<T>[]
  offset: number
  limit: number
  processingTimeMs: number
  query: string
}

export type Hit<T> = T & { _formatted?: T }

This to ensure that there may have a _formatted field in each object in the hits property.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:3
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
emyanncommented, Jun 9, 2020

@bidoubiwa Great! Here it is then https://github.com/meilisearch/meilisearch-js/pull/438! Please let me know if you have questions and feedbacks regarding my comments on the PR

2reactions
bidoubiwacommented, Jun 9, 2020

This is a great addition! Thanks a lot. If you make a PR I will accept it.

Btw, don’t forget to change it in line 243 of types.ts file.

search: (query: string, options?: SearchParams) => Promise<SearchResponse>
Read more comments on GitHub >

github_iconTop Results From Across the Web

Wrong type of @types/elasticsearch SearchResponse
When I use the ElasticsearchService of @nestjs/elasticsearch the result of the response doesnt match the type SearchResponse of ...
Read more >
Documentation - TypeScript for Functional Programmers
The resulting system is powerful, interesting and messy. This introduction is designed for working Haskell or ML programmers who want to learn TypeScript....
Read more >
A Beginner's Guide to using Typescript with React
Is it worth learning Typescript for developing React applications? Absolutely. I've found that having robust typing has led to more reliable ...
Read more >
How to type with TypeScript - codeburst
Most of the time TypeScript can understand the types by itself, using a technique called type inference. Here is what our code will...
Read more >
TypeScript support | Elasticsearch JavaScript Client [8.5] | Elastic
The client offers a first-class support for TypeScript, shipping a complete set of type definitions of Elasticsearch's API surface.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found