Skip to content

Instantly share code, notes, and snippets.

@njbmartin
Created April 4, 2021 04:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save njbmartin/c455c8b937c5fff7cb236e81df3e3aa2 to your computer and use it in GitHub Desktop.
Save njbmartin/c455c8b937c5fff7cb236e81df3e3aa2 to your computer and use it in GitHub Desktop.
interface Person {
firstName: string;
lastName: string;
email: string;
phone: string;
}
const person: Person = {
firstName: "Jane",
lastName: "Bloggs",
email: "jane@example.com",
phone: "0123456789"
};
console.log(person);
// expected output: email is a property
const personWithoutEmail: Omit<Person, "email"> = person
console.log(personWithoutEmail);
// expected output: email is not a property
// actual output: email is not a property, but is still part of the object. Oops!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment