ngrx / core

Core functionality for the ngrx platform
MIT License
72 stars 25 forks source link

[Suggestion] Improve SelectSignature with 'keyof T' #20

Open ribizli opened 7 years ago

ribizli commented 7 years ago
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