-
Notifications
You must be signed in to change notification settings - Fork 89
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
Post search route #529
Post search route #529
Conversation
5f8b8b9
to
df3da17
Compare
df3da17
to
88bc581
Compare
@bidoubiwa could you rebase your branch please? 🙂 |
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.
Just a suggestion, not sure about that: could we have the same tests running for the POST and then with the GET? The goal is to avoid tests duplication.
87d4c2e
to
a47722e
Compare
@bidoubiwa This is a Type widening behaviour in Typescript. One thing you could try is to use a describe.each([
{ method: 'POST' as const, },
{ method: 'GET' as const, },
])('Test on search', ({ method }) => {...}) Then the Does it answer your question ? :) |
@emyann Yes ! This worked great :) Thanks a lot for answering |
a47722e
to
3ac6b3d
Compare
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.
Question:
- What is the difference between
tests/search_tests.ts
andtests/typed_search_tests.ts
?
Plus, could you update the search
method prototype in the README? 🙂
} else { | ||
throw new MeiliSearchError( | ||
'method parameter should be either POST or GET' | ||
) |
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.
Cannot Typscript handle this part? 🙂
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.
Well, yes, but not if the user is not using typescript but javascript. In which case I prefer the error to be really obvious.
@@ -11,7 +11,7 @@ | |||
"declarationDir": "./dist/types", | |||
"esModuleInterop": true, | |||
"allowSyntheticDefaultImports": true, | |||
"lib": ["ES2015"] | |||
"lib": ["ES2015", "ESNext"] |
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.
What the purpose of ESNext? 🙂
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 are the rules to transpile typescript to javascript. By saying ESNext
I inform the transpiler that I will be writing with the last features of javascript. This will make it possible for me to write for example optionnal chaining. These features are not released in an official Ecmascript version but are bound to be in the next one.
if (response.data?.hits?.something)
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.
Thanks for the explanations! 😁
In
Which means that the compiler should raise an error if I try to access a field that does not exist in movie. interface Movie {
id: number
title: string
comment?: string
genre?: string
} response.hits[0].director // ERROR because director is not defined in Movie interface In response.hits[0].director // No errors but undefined |
This PR creates an additional parameter
method
on the search route. This lets the user decide if he wants to use thePOST
method (faster) or theGET
method.The tests in the CI will fail until MeiliSearch
v0.13.0
is out.Currently, tested with the
v0.13.0rc0
, tests are failing because of:Settings tests fixed in Settings changes #530-> merged-> merged404
on get system info tests: fixed in Remove sys-info and sys-info pretty #528Typescript issues
1 Itterating through an object with Typescrypt
The typings in the following code sample seems to be more complicated than it should be
2 Using fixed values as types in jest describe
Here is the type of my function
Here is how I do multiple tests on different methods:
As you can see I need to add the
if
condition because otherwise I recieve this error:I tried a lot of ways to add the types in the
describe
function but I couln't find how.@emyann maybe you have an idea ?