@@ -3,8 +3,10 @@ import { isPlatformBrowser } from '@angular/common';
3
3
import { bem , noop } from './utils' ;
4
4
import { NgAisInstantSearch } from './instantsearch/instantsearch' ;
5
5
import { NgAisIndex } from './index-widget/index-widget' ;
6
- import { Widget } from 'instantsearch.js/es/types' ;
7
- export { Widget } ;
6
+ import { Widget as W } from 'instantsearch.js/es/types' ;
7
+ import { IndexWidget } from 'instantsearch.js/es/widgets/index/index' ;
8
+
9
+ export type Widget = W | IndexWidget ;
8
10
9
11
// TODO: use Connector type from InstantSearch. Not yet possible now,
10
12
// since non-ts connectors can't have generics like Connector has,
@@ -14,11 +16,12 @@ export type Connector = (
14
16
unmountFn : ( ) => void
15
17
) => ( widgetOptions ?: object ) => Widget ;
16
18
17
- export abstract class BaseWidget implements OnInit , OnDestroy {
19
+ export abstract class BaseWidget < TState extends Record < string , unknown > = { } >
20
+ implements OnInit , OnDestroy {
18
21
@Input ( ) public autoHideContainer ?: boolean ;
19
22
20
23
public widget ?: Widget ;
21
- public state ?: object = { } ;
24
+ public state ?: TState = { } as TState ;
22
25
public cx : ReturnType < typeof bem > ;
23
26
public abstract instantSearchInstance : NgAisInstantSearch ;
24
27
public abstract parentIndex ?: NgAisIndex ;
@@ -49,7 +52,7 @@ export abstract class BaseWidget implements OnInit, OnDestroy {
49
52
}
50
53
51
54
public updateState = (
52
- state : { } ,
55
+ state : TState ,
53
56
isFirstRendering : boolean
54
57
) : Promise < void > | void => {
55
58
if ( isFirstRendering ) {
0 commit comments