I am trying to filter out properties from an object that are not defined in a specific type interface.
Suppose I have the following interface:
export interface CreateCustomerUserInput {
fullname: string;
email: string;
}
And this is my initial object:
let obj = {fullname: 'AAA', email: '<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="84e5e5c4e5e5aae7ebe9">[email protected]</a>', phone: '111', address: 'XXX'};
What I want is to create a new object with only the properties declared in the type interface. Here is the expected result:
let c = {fullname: 'AAA', email: '<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="ed8c8cad8c8cc38e8280">[email protected]</a>'}
Is there an efficient way to achieve this in TypeScript?