Skip to content
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

fix(types): improve UiState types #3763

Merged
merged 1 commit into from
May 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/lib/RoutingManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class RoutingManager implements Widget {
const widgets = this.instantSearchInstance.widgets;
const helper = this.instantSearchInstance.helper!;

return widgets.reduce((state, widget) => {
return widgets.reduce<UiState>((state, widget) => {
if (!widget.getWidgetState) {
return state;
}
Expand Down
8 changes: 4 additions & 4 deletions src/lib/__tests__/RoutingManager-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ describe('RoutingManager', () => {
});

const widgetState = {
some: 'values',
query: 'query',
};
const widget = {
render: () => {},
Expand All @@ -107,7 +107,7 @@ describe('RoutingManager', () => {
search.addWidget(widget);

const actualInitialState = {
some: 'values',
query: 'query',
};

search.start();
Expand Down Expand Up @@ -149,7 +149,7 @@ describe('RoutingManager', () => {
search.start();

const actualInitialState = {
some: 'values',
query: 'query',
};

const router = new RoutingManager({
Expand Down Expand Up @@ -182,7 +182,7 @@ describe('RoutingManager', () => {
search.addWidget(widget);

const actualInitialState = {
some: 'values',
query: 'query',
};

search.start();
Expand Down
40 changes: 39 additions & 1 deletion src/types/widget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,45 @@ interface DisposeOptions {
}

export type UiState = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The type does not contain: geoSearch, numericMenu.

[stateKey: string]: any;
query?: string;
menu?: {
samouss marked this conversation as resolved.
Show resolved Hide resolved
[attribute: string]: string;
};
/**
* The list of hierarchical menus.
* Nested levels must contain the record separator.
*
* @example ['Audio', 'Audio > Headphones']
*/
hierarchicalMenu?: {
[attribute: string]: string[];
};
refinementList?: {
[attribute: string]: string[];
};
numericRefinementList?: {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't have a numericRefinementList widget.

[attribute: string]: number;
};
numericSelector?: {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't have a numericSelector widget.

[attribute: string]: number;
};
/**
* The range as a tuple.
*
* @example '100:500'
*/
range?: {
[attribute: string]: string;
};
starRating?: {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The name is ratingMenu not starRating.

[attribute: string]: number;
};
toggle?: {
[attribute: string]: boolean;
};
sortBy?: string;
page?: number;
hitsPerPage?: number;
};

export interface Widget {
Expand Down