Hi there! My name is Arafat, and I am a computer science student and full-stack freelancer. I am passionate about using technology to solve real-world problems and constantly learning.
Extract creates a new type by selecting some of the original types, while Pick is used to create a new type by choosing some of the original properties.
Here's an example to illustrate the difference:
interfacePerson{name:string;age:number;email:string;phone:string;}// Extract a subset of types from PersontypePersonKeys=Extract<keyofPerson,'name'|'email'>;// Result: type PersonKeys = "name" | "email"// Pick some properties from PersontypePersonInfo=Pick<Person,'name'|'age'>;// Result: type PersonInfo = { name: string; age: number; }
Some comments have been hidden by the post's author - find out more
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Extractcreates a new type by selecting some of the original types, whilePickis used to create a new type by choosing some of the original properties.