core icon indicating copy to clipboard operation
core copied to clipboard

[Suggestion] Improve SelectSignature with 'keyof T'

Open ribizli opened this issue 8 years ago • 0 comments

export interface SelectSignature<T = any> {
  <R>(key: keyof T, ...paths: string[]): Observable<R>;
  <R>(mapFn: (state: T) => R): Observable<R>;
}

So TypeScript can check for using the correct key at least on the top level:

export interface MyState {
  myKey: any
}

...

Store<MyState> store;

store.select('myKey'); // fine
store.select('invalidKey'); // type error

ribizli avatar Jul 21 '17 07:07 ribizli