-
Notifications
You must be signed in to change notification settings - Fork 30.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[algoliasearch] Search Response
made generic
#33111
Conversation
Response made generic to allow better linting on the items of the `Reponse`
@neryortez Thank you for submitting this PR! 🔔 @CBaptiste @Haroenv @aherve @samouss @keichinger - please review this PR in the next few days. Be sure to explicitly select If no reviewer appears after a week, a DefinitelyTyped maintainer will review the PR instead. |
@@ -1842,8 +1843,8 @@ declare namespace algoliasearch { | |||
cursor?: string; | |||
} | |||
|
|||
interface MultiResponse { | |||
results: Response[]; | |||
interface MultiResponse<T=any> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The signature of the function is not helpful when we target different indices. The type of the record is different in most cases. With this signature the response only contain records of the same type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@keichinger is right. Either way, if you just have too many types, you can also leave blank like before:
client.search(...)
The T
type is optional.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, but you have to use a type guard to safely access your hit from the response. What I meant with my comment is: with this signature the response is not tightly coupled to a specific type which is the case with the single query signature.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@samouss All good?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes it’s better than nothing.
A definition owner has approved this PR ⭐️. A maintainer will merge this PR shortly. If it shouldn't be merged yet, please leave a comment saying so and we'll wait. Thank you for your contribution to DefinitelyTyped! |
I just published |
This is to allow better linting on the
hits
of theReponse
objectPlease fill in this template.
npm test
.)npm run lint package-name
(ortsc
if notslint.json
is present).If changing an existing definition:
tslint.json
containing{ "extends": "dtslint/dt.json" }
.