Closed tmac12 closed 1 year ago
Hello @tmac12
Based on the documentation link you provided, the warning is shown when you inject a typed Store in the constructor. This library does not inject Store. Are you sure this is a problem related to this library?
Hello @Odonno ,
when I use selectAreAllHubsConnected
it require a typed Store.
In a simple component I wanto to show a message if signalR is connected, so this is the component:
export class AppComponent {
title = 'realtime-app';
areAllHubsConnected$ = this.store.select(selectAreAllHubsConnected);
//Store required type "RootState"
constructor(private store: Store<RootState>) {
store.dispatch(createSignalRHub(feedHub));
}
}
in the constructor if I don't specify type RootState
I have this error:
No overload matches this call.
Overload 1 of 9, '(mapFn: (state: object) => boolean): Observable<boolean>', gave the following error.
Argument of type 'MemoizedSelector<RootState, boolean, DefaultProjectorFn<boolean>>' is not assignable to parameter of type '(state: object) => boolean'.
Types of parameters 'state' and 'state' are incompatible.
Property 'signalr' is missing in type '{}' but required in type 'RootState'.
Overload 2 of 9, '(key: never): Observable<never>', gave the following error.
Argument of type 'MemoizedSelector<RootState, boolean, DefaultProjectorFn<boolean>>' is not assignable to parameter of type 'never'.ts(2769)
I make a simple example of an working angular application here. When RootState is not defined it won't compile.
Thank you, Marco
Hi @tmac12
I did some research and what I found is that if you remove the generic type on Store
, its type becomes object
which is similar to an empty object {}
. This means that nothing inside the root state is accepted.
I have not found a workaround for this problem. IMO, I'd prefer to keep the typed/generic version. So I would suggest to disable the eslint rule if you can.
Hi @Odonno,
ok thank you so much. If I found another workaround I'll tell you.
When using store with this library I have this warning:
Store should not be typed, use Store (without generic) instead.
Example of code:
hubStatuses$ = this.store.select(selectHubsStatuses);
As described by official guide of NgRx, Store should not be typed.