As a newcomer to the Typescript environment, I am currently developing a test application to familiarize myself with it. However, I have encountered an issue regarding type restrictions that seems to be not working as expected.
In my class, I have defined an array as a member field like this:
listings: Array<ICryptListingItem> = [];
The interface ICryptListingItem is structured as follows:
export interface ICryptListingItem {
name: string;
something: number;
}
I am puzzled as to why the compiler allows me to do this:
this.listings = listings.data.map((listing) => {
return {
name: listing.name
}
});
The objects returned from the listings.data.map method do not fully implement the interface set for the array's type. What concept am I failing to grasp here?
Appreciate any insight you can provide. Thanks in advance.