I am new to Typescript and have a bit of trouble getting my code to work. I have the following interface / class structure
interface IInterface {
id : number;
method() : string;
}
class IClass implements IInterface {
id : number;
method() : string { return "foo";}
}
Now I want to get some data from the web service through the next call
$.get("/some/url", (data : Array<IInterface>) => {
for (var i = 0; i < data.length; i++) {
console.log(data[i].id);
console.log(data[i].method());
}
});
Although this compiles fine in Typescript, and all properties are set fine, I get a runtime TypeError data[i].method is not a function
So now my question is: how can I draw / assign (?) Correctly so that the methods are also available in the resulting JavaScript?
UPDATE As requested: Dump the data I get from the web service.
data = [{id : 1}, {id : 2}, ...]
, : / ( ), ( , , ).