Hello :) Version 2.1.0 of the JS SDK introduced a ...
# community-help
g
Hello :) Version 2.1.0 of the JS SDK introduced a new
Infix
parameter to the
MultiSearchResponse
object. Is there any documentation about what to provide to this parameter? The version introduced quite a few changes to the types but no migration was documented. Great to see types improving, but not super nice to introduce breaking changes without proper doc 😛
f
The
MultiSearchResponse
type isn't meant to be explicitly defined by the user. It also provides a default generic of
string
, which passes the type check. It's meant for comma-separated strings
g
I use
MultiSearchResponse
as parameter to a function that transform the search results to the datatype needed in the app, hence why I use it. The TypeSense schema does not exactly match what is used in the app ; the schema was adapted to take the most of TypeSense. Would there be a more fitting type?
Currently, I use the type this way:
Copy code
MultiSearchResponse<Typesense.MultisearchSchemas>
With this, TS complains 2 or 3 params are required 🙂
f
Which version of the js library are you on? You can see this using
npm list
Can you update to
2.1.0-13
if you're not on that?
1
g
2.1.0
Capture d’écran 2025-08-26 à 18.00.43.png
f
Sorry, use
npm install typesense@next
g
Okay, so 3.0.0-0, correct?
It have the same issue with 3.0.0-0
f
I think a better approach to this would be to use the return type of the function call itself. It will have all the info regarding the response without needed to fill up the generics
g
I built this type:
Copy code
export type MultisearchSchemas = [
    CompanyDocumentSchema,
    ProjectDocumentSchema,
    ReportDocumentSchema,
    RequestDocumentSchema,
    TranscriptDocumentSchema,
  ];  

export type MultiSearchResponse = Awaited<
    ReturnType<
      typeof TypeSenseMultiSearch.prototype.perform<Typesense.MultisearchSchemas>
    >
  >;
One suggestion if I may: MultiSearch.perform has two definitions. The union version has a dedicated type (
UnionSearchResponse
), but not the non-union one. It would be nice if the non-union version had a dedicated response type too, so I could use it directly 🙂
These are the definition I found:
f
If you invoke the mutlisearch function, based on the argument passed in, the response type will be different. If you then use
typeof
on the object built by the function call, you can then use that
1
g
Thanks for the help Fanis ! 🙂