haejunejung / ts-typekit

🧰 A Collection of TypeScript Utility Types
https://ts-typekit.vercel.app
MIT License
9 stars 0 forks source link

Support for `PickOptional` #47

Closed haejunejung closed 2 months ago

haejunejung commented 2 months ago

It provides support for PickOptional. Related to #46.

In TypeScript, there are situations where you need to make specific properties of a type optional, while keeping the rest of the type unchanged. The PickOptional type is designed for this purpose.

It allows you to select certain properties from a type and enforce that they are optional, while leaving other properties as they are.

Here is a more detailed example.

type User = {
  id: number;
  name: string;
  email: string;
}

type NameOptionalUserProps = PickOptional<User, 'name'>;
// Result will be: { id: number; name?: string; email: string; }