Confusion arises as to why the TypeScript error is triggered in this piece of code. (Please disregard the irrelevant example given):
interface Images {
[key:string]: string;
}
function getMainImageUrl(images: Images): string {
return images.main;
}
Encountering the following error message when using TypeScript 1.7.5:
error TS2339: Property 'main' does not exist on type 'Images'.
To resolve this error, one could simply do:
return images["main"];
However, an alternative solution without resorting to strings for property access would be preferable. Any suggestions?