Created
September 20, 2025 06:03
-
-
Save av1v3k/c1806d1b1c6065d2b46e6bfd493d1bd6 to your computer and use it in GitHub Desktop.
Difference between Pick and Omit in Typescript
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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