2026/7/23
Practicing implementing utility types's thumbnail

Practicing implementing utility types

  • TypeScript

TypeScript provides a lot of utility types. These are not only convenient but also teach us TypeScript syntax. For example, Pick is used to create a type that selects specific properties from a type of an object. We can learn four important syntax features from this:

So that’s a good way to get familiar with and remember type operations, I think.

type Profile = {  name: string;  age: number;  blog: string;  description: string;};type Pick2<T, U extends keyof T> = {  [K in U]: T[K];};// type Bio = Pick<Profile, "blog" | "description"> -> { blog: string; description: string; }type Bio = Pick2<Profile, 'blog' | 'description'>;const bio: Bio = {  blog: 'https://ymmr.dev',  description: 'xxxx',};