Skip to content

AdditionalSearchParameters type behavior #242

@ValPolOff

Description

@ValPolOff

Hi
I recently upgraded the following packages in my project:

"typesense": "^2.0.3",
"typesense-instantsearch-adapter": "^2.9.0"

Previously, I was using:

"typesense": "^1.4.4",
"typesense-instantsearch-adapter": "^2.8.0"

In version 2.8.0, when passing invalid values to additionalSearchParameters, TypeScript would throw type errors — for example, if I did:

additionalSearchParameters: {
  group_limit: 'lol', // ❌ TS error
}

This was helpful for catching mistakes early.

However, in 2.9.0, this type-checking seems to be relaxed — now TypeScript doesn't complain about incorrect values in additionalSearchParameters, even though they may still cause a runtime RequestMalformed error from the API.

Could you clarify:

Was this relaxed type behavior intentional?

Is there a recommended way to enforce strict typing on additionalSearchParameters in the latest version?

Another reason I updated the library is related to the infix parameter. In v2.8.0, the type expects an array:

infix: ['off', 'off', 'always'] // ✅ TS accepts this

But when using this with a Typesense cluster running v28, it results in an error:
RequestMalformed: Request failed with HTTP code 400 | Server said: One or more search parameters are malformed.
After reviewing the documentation, I discovered that the server expects a comma-separated string like:
infix: 'off, off, always' // ✅ works at runtime
But then I had to bypass TypeScript like this:
infix: 'off, off, always' as any

Could you please clarify:

What is the correct type for infix expected by the server in v28?

Should the types in the adapter match this format (i.e., allow a string)?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions