I'm new to typescript and I have interface in typescript like this:
interface Model{
class : String,
id: Number
}
and in my model class, I have used this interface like this:
class MyModel{
model: Array<Model> = []
pushData(val){
model.push(val) //error happens here
}
}
On compilation typescript seems to be throwing error:
error TS2345: Argument of type '{}' is not assignable to parameter of type 'Model'.
Property 'class' is missing in type '{}'.
I have checked the value of val
is nothing but:
{
class : "test", id : 123
}
which is matching my interface, then why typescript throws this error?
Typescript version is 1.6.2