-
Notifications
You must be signed in to change notification settings - Fork 90
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
Add rankingScore and rankingScoreDetails types #1537
Add rankingScore and rankingScoreDetails types #1537
Conversation
_rankingScoreDetails?: Record<string, any> | ||
} | ||
|
||
export type RakingScoreDetails = { |
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.
Is there any way to add comments to these types, to make them highlight the IDEs of people using it?
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, I realised I forgot to use RankingScoreDetails
hehe. But to answer your question this is how IDe works w/ typescript types.
By clicking on go to type definition
you'll be redirection to the RankingScoreDetails
type.
Now, I can add a comment like this:
Which would appear like that if I hover over the type (see last line of second screen):
|
||
const hit = response.hits[0] | ||
|
||
expect(response).toHaveProperty('hits', expect.any(Array)) |
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.
This assertion is not valid since you'll have a broken code anyway. In the line before you ensure you're taking the first item from an array :)
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.
I'm not asserting hit
but response
. Not sure why it's broken
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.
hits will always be an array, that's my point. Otherwise you'll have an exception!
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.
In your assertion, you're telling that you expect the hits key to be an array. And that will never fail.
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.
Oh yes, it's a test that tests Meilisearch not my SDK haha. It's a copy paste from other tests I can remove it
Related to:
issue: meilisearch/meilisearch#3771
spec: meilisearch/specifications#252
What does this PR do?
showRankingScore
andshowRankingScoreDetails
_rankingScore
and_rankingScoreDetails
in the returned hits depending on the enabled features