Below is the code I am currently working with:
get tags(): { [key: string]: string }[] {
let tags: { [key: string]: string }[] = [];
if(this.tags) {
Object.keys(this.tags).forEach(x => {
tags.push({ prop1: this.tags[x], prop2: getVal(x)});
});
}
return tags;
}
I find it strange that the return type matches even though it seems like it shouldn't. Can someone clarify why this is happening?
Would it be better to use the following code instead?
get tags(): { prop1: string, prop2: string }[] {
let tags: { prop1: string, prop2: string }[] = [];
if(this.tags) {
Object.keys(this.tags).forEach(x => {
tags.push({ prop1: this.tags[x], prop2: getVal(x)});
});
}
return tags;
}