Skip to content

Instantly share code, notes, and snippets.

@av1v3k
Created September 20, 2025 06:03
Show Gist options
  • Select an option

  • Save av1v3k/c1806d1b1c6065d2b46e6bfd493d1bd6 to your computer and use it in GitHub Desktop.

Select an option

Save av1v3k/c1806d1b1c6065d2b46e6bfd493d1bd6 to your computer and use it in GitHub Desktop.
Difference between Pick and Omit in Typescript
interface Address {
street: string;
area: string;
landmark: string;
pincode: number;
}
type previewAddress = Pick<Address, 'pincode' | 'area'>;
type previewAddress2 = Omit<Address, 'pincode'>;
const address: previewAddress = {
pincode: 4,
area: ''
}
const address2: previewAddress2 = {
street: '',
area: '',
landmark: ''
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment