When attempting to call my function, I am encountering an error. Interestingly, everything works fine when I create just one object of someClass and then utilize the greet function.
This is what does not work (someArray being an array of type someClass):
for (let i = 0; i < this.someArray.length; i++) {
this.someArray[i].greet();
}
However, the following code snippet does work:
let oneInstance: someClass = new someClass;
oneInstance.id = 'abc';
console.log(oneInstance.greet());
In this scenario, SomeArray represents an array of my class called someClass:
export class someClass implements ISomeClass {
id: string;
public greet() {
return "Hello, " + this.id;
}
}