ngrx/store select 不存在

ngrx/store select does not exist

我正在尝试使用以下代码重新创建 ngrx/store 示例项目,我知道这对于 TODO 应用程序来说有点矫枉过正,但我​​想了解一下这些概念:

// State Model
interface Todo {
  id: number;
  text: string;
  completed: boolean;
}

interface TodoState {
  entities: Todo[];
}

interface AppState {
  todos: TodoState;
}

// State Retrieval
getTodos() {
  return (state: Observable<TodoState>) => state.select(s => s.entities);
}

getTodoState() {
  return (state: Observable<AppState>) => state.select(s => s.todos);
}

getTodosCollection() {
  return compose(this.getTodos(), this.getTodoState());
}

@Component({...})
class App {
  // I'd think I should be able to type this to Array<Todo>,
  // but that throws a compile-time error.
  // Also, I'm assuming the $ is convention to designate
  // a stream.
  todos$: Observable<any>;

  constructor(private store:Store<AppState>) {
    this.todos = store.let(this.getTodosCollection());
  }

}

这段代码造成了两个编译时错误:

Property 'select' does not exist on type 'Observable<TodoState>'.
Property 'select' does not exist on type 'Observable<AppState>'.

我在 Observable 导入上尝试了很多不同的变体,但这似乎并不重要,所以我只采用了示例应用程序的内容:

import {Observable} from 'rxjs/Observable';

如有任何帮助,我们将不胜感激!

您似乎没有导入 select 让我们尝试添加以下导入:

import '@ngrx/core/add/operator/select';
import 'rxjs/add/operator/let';