[Vuejs]-Argument of type 'DocumentData' is not assignable to parameter of type 'never'

0👍

It’s strange that the solution you linked didn’t work for you, but you could try asserting the type using the as keyword.

Also, you should move the data id assignment into the if statement, otherwise you risk getting the error Cannot set property 'id' of undefined at runtime:

if (commentaires) {
  commentaires.id = data.id;
  this.postComments.push(commentaires as DocumentData);
}

0👍

i found solution :
here the change :

 async viewPost ({ state, commit }, post: { id?: any }): Promise<void> {
  const postComments: firebase.firestore.DocumentData[] = []
  const allCommentaires = await commentsCollection.where('postId', '==', post.id).get()
  if (allCommentaires) {
    allCommentaires.forEach(data => {
      const commentaires = data.data()
      commentaires.id = data.id
      if (commentaires !== undefined) {
        postComments.push(commentaires)
      }
    })
  }
},

Leave a comment