I stumbled upon this particular post (and also this one) while searching for a solution to my issue.
I am looking to suppress these specific errors:
'Payload' property is missing from the 'Matatu' type.
'Key' property is not found on type 'Matatu'.
I have attempted to define variables to go around the type system, but without success.
Below you can find my .ts
code and what I have tried so far:
import { Component } from '@angular/core';
import { IonicPage, NavController, NavParams, ActionSheetController } from 'ionic-angular';
import { AngularFireList, AngularFireDatabase } from 'angularfire2/database';
import { Matatu } from '../../models/matatu/matatu.interface';
/* imports */
declare var payload;
declare var key;
@IonicPage()
@Component({
selector: 'page-owner-dash',
templateUrl: 'owner-dash.html',
})
export class OwnerDashPage {
matatuListRef$: AngularFireList<Matatu>;
matatuListAsync$: any;
constructor(public navCtrl: NavController, public navParams: NavParams, private database: AngularFireDatabase, public actionShtCrtl: ActionSheetController) {
this.matatuListRef$ = this.database.list('matatu-list');
this.matatuListAsync$ = this.matatuListRef$.snapshotChanges();
}
ionViewDidLoad() {
//things
}
selectMatatu(matatu: Matatu){
this.actionShtCrtl.create({
title: `${matatu.payload.val().matNumberPlate}`,
buttons: [
{
text: 'Edit',
handler: () => {
//actions
}
},
{
text: 'Delete',
role: 'destructive',
handler: () => {
this.matatuListRef$.remove(matatu.key);
}
},
{
text: 'Cancel',
role: 'cancel',
handler: () => {
//perform some actions
}
}
]
}).present();
}
}
Below is the structure of Matatu
:
export interface Matatu {
$key?: string;
matNumberPlate: string;
matSacco: string;
matDriver: string;
matAccessCode: string;
matStatus: string;
matTracker: string;
matLocation: string;
}
How can I convert the property to any data type?