Skip to content

Commit

Permalink
fix: remove useless types (#3958)
Browse files Browse the repository at this point in the history
* fix: remove useless types

* fix: remove useless cast/ignore
  • Loading branch information
samouss authored and Haroenv committed Oct 23, 2019
1 parent e94752d commit ddebf53
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 28 deletions.
2 changes: 0 additions & 2 deletions src/connectors/query-rules/connectQueryRules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,6 @@ const connectQueryRules: QueryRulesConnector = (render, unmount = noop) => {

// We track every change in the helper to override its state and add
// any `ruleContexts` needed based on the `trackedFilters`.
// @ts-ignore
// @TODO: we have to update the definition to make it work
helper.on('change', onHelperChange);
}

Expand Down
2 changes: 0 additions & 2 deletions src/lib/RoutingManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,6 @@ class RoutingManager implements Widget {
this.router.write(route);
};

// @ts-ignore
// @TODO: we have to update the definition to make it work
helper.on('change', this.renderURLFromState);

// Compare initial state and first render state to see if the query has been
Expand Down
34 changes: 12 additions & 22 deletions src/lib/utils/mergeSearchParameters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,30 +35,20 @@ const mergeDisjunctiveFacets: Merger = (left, right) =>
left
);

type HierarchicalFacet = {
name: string;
attributes: string[];
separator: string;
};

const mergeHierarchicalFacets: Merger = (left, right) =>
left.setQueryParameters({
// @TODO: remove this cast when typings in helper are merged
hierarchicalFacets: (right.hierarchicalFacets as HierarchicalFacet[]).reduce(
(facets, facet) => {
const index = findIndex(facets, _ => _.name === facet.name);

if (index === -1) {
return facets.concat(facet);
}

const nextFacets = facets.slice();
nextFacets.splice(index, 1, facet);

return nextFacets;
},
left.hierarchicalFacets as HierarchicalFacet[]
),
hierarchicalFacets: right.hierarchicalFacets.reduce((facets, facet) => {
const index = findIndex(facets, _ => _.name === facet.name);

if (index === -1) {
return facets.concat(facet);
}

const nextFacets = facets.slice();
nextFacets.splice(index, 1, facet);

return nextFacets;
}, left.hierarchicalFacets),
});

// Merge facet refinements
Expand Down
1 change: 0 additions & 1 deletion src/types/instantsearch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ export type Client = AlgoliaSearchClient;

export type InstantSearch = {
helper: AlgoliaSearchHelper | null;
widgets: Widget[]; // @TODO: remove once the RoutingManger uses the index
mainHelper: AlgoliaSearchHelper | null;
mainIndex: Index;
insightsClient: AlgoliaInsightsClient | null;
Expand Down
1 change: 0 additions & 1 deletion test/mock/createInstantSearch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ export const createInstantSearch = (
return {
mainIndex,
mainHelper,
widgets: [], // @TODO: remove once the RoutingManger uses the index
helper: mainHelper, // @TODO: use the Helper from the index once the RoutingManger uses the index
templatesConfig: {},
insightsClient: null,
Expand Down

0 comments on commit ddebf53

Please sign in to comment.