类型“ {}”上不存在属性“键”

时间:2019-05-12 18:20:00

标签: typescript firebase ionic3 angularfire2

我明白了,错误说属性'key'在类型'{}'上不存在。

  getLastMessageForUser(): Observable<Message[]> {
      return this.auth.getAuthenticatedUser()
          .map(auth =>auth.uid)
          .mergeMap(authId => this.db.list(`last-messages/${authId}`)
          .snapshotChanges())
          .mergeMap(lastMessages =>
              Observable.forkJoin(
                  lastMessages.map(message =>
                     this.db.object(`/messages/${message.payload.val().key}`).valueChanges().first()),
                  (...vals) => {
                    console.log(vals);
                      return vals;
                  })
          )

此功能应该给我用户的最后消息。如何更改message.payload.val()。key?


打字稿版本3.2.2

0 个答案:

没有答案