0

I'm trying to delete a key from an object in Typescript.

The Object is coming from firestore. FriendID is a var (string);

userObj = getDocument.data()['friendsObj'];
delete userObj[friendID];

In previous code, I checked if userMap 'contains' the friendID. If that's the case I use this code. But I get the error:

Element implicitly has an 'any' type because expression of type 'any' can't be used to index type 'Map<any, any>'.

Is it because it doesn't now the exact value of the userMap and friendID?

Thanks!

EDIT:

Example friendsID: "1KDL8932"

Example userObj: { K79DFS: 'Bob', 1KDL8932: 'Jeff'}

Karel Debedts
  • 5,226
  • 9
  • 30
  • 70

0 Answers0