-
Notifications
You must be signed in to change notification settings - Fork 222
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
proposal: re-exports all types in algoliasearch
#1080
Comments
Yes, we should make sure that you don't need to reach into implementation details to be able to fully use the types (they aren't always inferred if you wrap the client e.g.) |
Yes please |
+1, this took me quite a while to work out why I couldn't import things directly from algoiasearch. |
Any update to this topic? |
Reopening the pull request, I lost track of it. Thanks @wiesson ! |
@Haroenv no problem :) I kind of solved it for now: import type { RequestOptions } from "@algolia/transporter";
import type { SearchOptions } from "@algolia/client-search";
// hacky attempt to remove readonly
type Mutable<T> = { -readonly [P in keyof T]: T[P] };
(...)
let requestOptions: Partial<RequestOptions & Mutable<SearchOptions>> = {
hitsPerPage: resultsPerPage,
};
if (page) {
requestOptions.page = page;
}
if (lat && lng) {
requestOptions.aroundLatLng = `${lat}, ${lng}`;
requestOptions.aroundRadius = radius * 1000;
}
if (boundingBox) {
requestOptions.insideBoundingBox = [boundingBox];
}
const { hits, nbHits, page, nbPages } = await searchIndex.search(q, requestOptions);
(...) |
This is still an issue, two years later after the first request. The current version of algoliasearch still doesn't have access to types, we need to install several unnecessary packages only for types. Any progress on this? |
Any workaround on this issue? |
All types are exported, but from other packages, like @algolia/client-search, so you can look into the reference and find the import that way. |
done in v5 |
@shortcuts Is this issue also related to this error that I'm getting locally and in CI? This started happening recently and it's a bit confusing as to what might have triggered this issue. Here's the log output I'm seeing from CI:
It would appear that this issue is stemming from inside the package, but I could be wrong. |
Today, types like
SearchOptions
, orRule
are not exported by thealgoliasearch
package.People are actually importing them directly from the modular packages:
Solution: re-exports all types, and types from modular packages, in
algoliasearch
and configure API Extrator to warn us about non exported types.The text was updated successfully, but these errors were encountered: