I am facing a typescript error in my code, specifically in the tslint plugin of Atom editor. Unfortunately, I am struggling to determine how to correctly set the type.
Error message: https://i.sstatic.net/VU3ee.png
Here is the code snippet for the chat component:
private _chatObserver: Observable<firebase.database.DataSnapshot>
otherMethod () {
this._chatObserver = this._chat.observe(alarmId)
this._chatObserver.subscribe(
(messageSnap: firebase.database.DataSnapshot) => {
this.messages.push(messageSnap.val())
},
error => {throw error})
}
ionViewDidLeave() {
this._chatObserver.unsubscribe()
}
And here is the code snippet for the _chat provider:
public observe (alarmId){
let messagesRef = this._ref.child(`alarms/${alarmId}/messages`)
const observable = Observable.create(observer => {
messagesRef.on('child_added',(messageSnap) => {
observer.next(messageSnap)
},
(error) => observer.error(error)
)
return () => {
messagesRef.off('value')
};
});
return observable
}