I'm typescript beginner.
What is difference between Pick and T["properties"] index reference?
For example:
interface Generic {
   red: number
   apple: string;
   
}
type RedType = Pick<Generic, "red">
type RedType2 = Generic["red"]
                The first example picks only certain properties of an object and returns an object type
type RedType = Pick<Generic, 'red'>; // { red: number }
The second example gives you the type of the referenced property on an object
type RedType2 = Generic["red"]; // number
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With