I am looking to extract only specific properties from a given object. Can TypeScript interfaces be used to iterate through the data and eliminate unnecessary properties?
Sample data:
[
0: {
"original_language" : "en",
"title" : "The First Title",
"original_title" : "The First Original Title",
"overview": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin ac suscipit nulla.",
"release_date": "2022-05-04",
"popularity": 9411.64
},
1: {
"original_language" : "en",
"title" : "The Second Title",
"original_title" : "The Second Original Title",
"overview": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin ac suscipit nulla.",
"release_date": "2022-05-04",
"popularity": 9411.64
},
2: {
"original_language" : "es",
"title" : "The Third Title",
"original_title" : "The Third Original Title",
"overview": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin ac suscipit nulla.",
"release_date": "2022-05-04",
"popularity": 9411.64
}
]
Desired object properties (Typescript Interface):
interface IMovie {
overview: string,
release_date: Date,
title: string
}
My attempt at creating a mapper function:
const movieMapper = (movies: []): [IMovie] => {
return movies.map(movie => <IMovie>movie);
}