Skip to content

Commit

Permalink
chore(core): migrate core file to TS (#3984)
Browse files Browse the repository at this point in the history
* chore(core): migrate core file to TS

this depends on:

- DefinitelyTyped/DefinitelyTyped#37105
- algolia/algoliasearch-helper-js#739

* chore: undo needless change

* chore: add type info

* chore(enhanceConfiguration): prevent helper to be superfluously created (#3959)

* fix(enhanceConfiguration): create SearchParameters once less

* test: add test for hierarchicalFacets

this test failed with the old mergeDeep-based enhanceConfiguration

* create helpers outside of enhanceConfiguration

* chore: more consistent type

* getConfiguration now gets called with SearchParameters only

* update existing TS widgets to make tsc pass

* chore: change conditional style to be more readable

* chore: clarify TODO

* avoid extra constructor call

* chore: go back to old behaviour, test later

* chore: remove import

* chore: reuse parameters instance

* chore: update @types/algoliasearch

* chore: move files around

* move more (also routing now)

* chore: make index' options a subset

* chore: undo readability change

* chore: remove unusted

* chore(configure): make TS pass

* Update src/types/widget.ts
  • Loading branch information
Haroenv authored and samouss committed Sep 17, 2019
1 parent dd8d1d0 commit 1addb3b
Show file tree
Hide file tree
Showing 17 changed files with 375 additions and 278 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
"@storybook/addon-actions": "5.1.11",
"@storybook/html": "5.1.11",
"@storybook/theming": "5.1.11",
"@types/algoliasearch": "3.30.14",
"@types/algoliasearch": "3.30.16",
"@types/classnames": "^2.2.7",
"@types/enzyme": "^3.1.15",
"@types/enzyme-adapter-react-16": "^1.0.3",
Expand Down
9 changes: 3 additions & 6 deletions src/connectors/configure/connectConfigure.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import algoliasearchHelper, {
AlgoliaSearchHelper,
} from 'algoliasearch-helper';
import {
InstantSearchOptions,
Renderer,
RendererOptions,
Unmounter,
Expand Down Expand Up @@ -80,7 +79,6 @@ const connectConfigure: ConfigureConnector = (
}

type ConnectorState = {
instantSearchInstance?: InstantSearchOptions;
refine?: Refine;
};

Expand Down Expand Up @@ -114,24 +112,23 @@ const connectConfigure: ConfigureConnector = (
},

init({ instantSearchInstance, helper }) {
connectorState.instantSearchInstance = instantSearchInstance;
connectorState.refine = refine(helper);

renderFn(
{
refine: connectorState.refine!,
instantSearchInstance: connectorState.instantSearchInstance,
instantSearchInstance,
widgetParams,
},
true
);
},

render() {
render({ instantSearchInstance }) {
renderFn(
{
refine: connectorState.refine!,
instantSearchInstance: connectorState.instantSearchInstance,
instantSearchInstance,
widgetParams,
},
false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import algoliasearchHelper, {
SearchResults,
SearchParameters,
} from 'algoliasearch-helper';
import { Client } from 'algoliasearch';
import { createInstantSearch } from '../../../../test/mock/createInstantSearch';
import {
createInitOptions,
Expand All @@ -11,8 +12,6 @@ import { createSingleSearchResponse } from '../../../../test/mock/createAPIRespo
import { TAG_PLACEHOLDER } from '../../../lib/escape-highlight';
import connectInfiniteHits from '../connectInfiniteHits';

import { Client } from '../../../types';

jest.mock('../../../lib/utils/hits-absolute-position', () => ({
// The real implementation creates a new array instance, which can cause bugs,
// especially with the __escaped mark, we thus make sure the mock also has the
Expand Down
Loading

0 comments on commit 1addb3b

Please sign in to comment.