I'm having a typescript error with my Ionic/Angular application. Below it says:
Type 'string[]' cannot be used as an index type.
Which I don't understand. The entire error is:
[17:57:57] typescript: C:/xampp/htdocs/project x/anonymous-social/src/pages/threads/threads.ts, line: 58 Type 'string[]' cannot be used as an index type.
L58: let threadId = Object(snapshot.val()[Object.keys(snapshot.val())]).threadId;
L59: let messageCount = snapshot.val().unread || 0;
My code that goes along with this is:
this.database.database.ref('/users/'+this.userData.uid+'/threads/')
.orderByChild('threadId')
.on('child_added', (snapshot) => {
let threadId = Object(snapshot.val()[Object.keys(snapshot.val())]).threadId;
let messageCount = snapshot.val().unread || 0;
rec.push(Object(snapshot.val()[Object.keys(snapshot.val())]));
Any idea why this might be happening? I don't completely understand... Any help would be great!