proposal: re-exports all types in `algoliasearch`
Today, types like SearchOptions, or Rule are not exported by the algoliasearch package.
People are actually importing them directly from the modular packages:
import { SearchOptions } from '@algolia/client-search';
Solution: re-exports all types, and types from modular packages, in algoliasearch and configure API Extrator to warn us about non exported types.
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.