Skip to content
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

fix(ts): correct search response for facets_stats #1229

Merged
merged 1 commit into from
Nov 20, 2020

Conversation

Haroenv
Copy link
Contributor

@Haroenv Haroenv commented Nov 19, 2020

@eunjae-lee
Copy link
Contributor

Huh weirdly only key not in camelCase
https://www.algolia.com/doc/api-reference/api-methods/search/#method-response-facets_stats

@codesandbox-ci
Copy link

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

@Haroenv Haroenv merged commit ac732d1 into master Nov 20, 2020
@Haroenv Haroenv deleted the fix/ts-facets-stats branch November 20, 2020 09:09
Haroenv added a commit to algolia/instantsearch that referenced this pull request Nov 20, 2020
Basically we had two methods to turn a number (or string) into a precision:

1. Math.floor(min * pow) / pow
2. Number(Number(v).toFixed(precision))

these behave different for precision 0 & a number over .5, let's say 1.5 turns into 1 for method 1, and into 2 for method 2. This is a bug (not caught by most of our tests, notably the ones i had to change) and causes the range to change to a number it's not supposed to be. Pay special attention to the new `toPrecision` utility, and the places it was used.

At the same time I also converted to TypeScript, but not the components themselves, since that was too much work.

typescript for tests is expected to fail until algolia/algoliasearch-client-javascript#1229 is released (since now certain parts aren't random objects, but rather search responses)

The version for the helper is bumped for better typescript support as well.
Haroenv added a commit to algolia/instantsearch that referenced this pull request Nov 30, 2020
Basically we had two methods to turn a number (or string) into a precision:

1. Math.floor(min * pow) / pow
2. Number(Number(v).toFixed(precision))

these behave different for precision 0 & a number over .5, let's say 1.5 turns into 1 for method 1, and into 2 for method 2. This is a bug (not caught by most of our tests, notably the ones i had to change) and causes the range to change to a number it's not supposed to be. Pay special attention to the new `toPrecision` utility, and the places it was used.

At the same time I also converted to TypeScript, but not the components themselves, since that was too much work.

typescript for tests is expected to fail until algolia/algoliasearch-client-javascript#1229 is released (since now certain parts aren't random objects, but rather search responses)

The version for the helper is bumped for better typescript support as well.

update types

requires algolia/algoliasearch-client-javascript#1234

update client for fix in typing for tests

update assertions in changed tests

clarify why behaviour is like it is
Haroenv added a commit to algolia/instantsearch that referenced this pull request Dec 2, 2020
* fix(range): consistently convert min & max to numbers

Basically we had two methods to turn a number (or string) into a precision:

1. Math.floor(min * pow) / pow
2. Number(Number(v).toFixed(precision))

these behave different for precision 0 & a number over .5, let's say 1.5 turns into 1 for method 1, and into 2 for method 2. This is a bug (not caught by most of our tests, notably the ones i had to change) and causes the range to change to a number it's not supposed to be. Pay special attention to the new `toPrecision` utility, and the places it was used.

At the same time I also converted to TypeScript, but not the components themselves, since that was too much work.

typescript for tests is expected to fail until algolia/algoliasearch-client-javascript#1229 is released (since now certain parts aren't random objects, but rather search responses)

The version for the helper is bumped for better typescript support as well.

update types

requires algolia/algoliasearch-client-javascript#1234

update client for fix in typing for tests

update assertions in changed tests

clarify why behaviour is like it is

* address feedback

* integrate fix from the helper avoiding workaround here
@nojvek
Copy link

nojvek commented Jun 14, 2021

Just want say, thanks for fixing this. This has led me to at-least five // @ts-expect-error comments within the codebase.

@Haroenv
Copy link
Contributor Author

Haroenv commented Jun 15, 2021

Thanks @nojvek, if there's other places where you're currently suppressing errors, feel free to open pull requests / issues for that!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants