Use the powerful typing from typescript for SearchResponse
See original GitHub issueHey! 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:
- Created 3 years ago
- Reactions:3
- Comments:7 (7 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@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
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.