mercredi 5 septembre 2018

typescript use class/interface to delete properties from an object

I have the following object:

{
   name: 'Jon',
   gender: 'male',
   secret: 'xxx'
}

and the interface:

interface PublicUserData {
    name: string
    gender: string
}

Can I somehow iterate all properties of PublicUserData and delete all properties from the other object that are not present in the interface?

I know that I will have to use reflect-metadata to get that info, but I would need some hint on now to point me into the right direction





Aucun commentaire:

Enregistrer un commentaire