I want to remove all properties from an object which are not declared in a specific type interface.
For example, let's assume that I have the following interface:
export interface CreateCustomerUserInput {
fullname: string;
email: string;
}
And I have the following object:
let obj = {fullname: 'AAA', email: 'aa@aa.com', phone: '111', address: 'XXX'};
But I want to create a new object with only properties declared in the type interface. Here is the expected object:
let c = {fullname: 'AAA', email: 'aa@aa.com'}
Is there any good way to solve this in TypeScript?