-
Notifications
You must be signed in to change notification settings - Fork 129
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
Switch to stronger typings #229
Comments
Hi @D34THWINGS , Consider that, while by default documents are assumed to be plain key/value objects, The current API is designed to be “additive”: common cases are simple, and more advanced options are layered on top, without making the basic API more complex. I understand the appeal of a strict type design, but that tends to impose a level of complexity (even in the type definitions) that most users are not comfortable with. It's ultimately a matter of project direction, but ergonomics matter more than strict type safety for me in this case. One viable option that does not involve breaking changes is to implement a strictly typed thin wrapper around MiniSearch. |
I think that the suggestion made by @juiceo here is quite interesting, and a pretty good one for an API targeted at TypeScript only. I still believe that imposing such breaking change to everyone would be a bad trade off, but that's the direction I would investigate for a thin wrapper improving type safety for TypeScript users. |
I've been using
minisearch
for a few weeks now and I think the TypeScript typing is not really there. It's way too loosely typed with too manyany
being returned, this is quite dangerous and should not be done in a modern library.The configuration options of the MiniSearch class should take into account the keys available given in the dynamic typing:
Then the search result should also return only the
storeFields
if present or the entire record otherwise instead ofRecord<string, any>
which is quite unsafe to use as you no longer have field validation on it.If you agree with this I could open a pull request, but it would probably mean going for v7 of the package as this would be a breaking change for TS users.
The text was updated successfully, but these errors were encountered: