TypeError: unknown type returned

TypeError: unknown type returned

我正在使用 ngrx/effects。我收到此错误:

ORIGINAL EXCEPTION: TypeError: unknown type returned

这是我的部分代码:

  this.store.dispatch({ type: CHAT_LOAD_MESSAGES, payload: chatId });

  @Effect() loadMessages$ = this.updates$
    .whenAction(CHAT_LOAD_MESSAGES)
    .map<string>(toPayload)
    .do(chatId => console.log('chatId', chatId))    // Here I can get chatId
    .switchMapTo(chatId => this.chatService.loadMessages(chatId))  // The error comes out because of this line
    .do(res => console.log('res', res))             // This didn't run
    .map((messages: Message[]) => ({ type: CHAT_LOAD_MESSAGES_SUCCESS, payload: messages }));

  loadMessages(chatId: string): Observable<Message[]> {
    // This is what I am using to test right now.
    // Maybe this line is wrong? How can I write correct simulation?
    return Observable.of([{ id:1, content:'Hi' });
  }

这可能是什么原因造成的?谢谢

感谢@apreg 指出我在 Gitter 上的错误。

我应该将 switchMapTo 更改为 switchMap

switchMap and switchMapTo的官方文档及解释。