PartialPick
by default, the partial makes everything optional, but you can use this type to make a partial pick of a type.
by default, the partial makes everything optional, but you can use this type to make a partial pick of a type.
import { PartialPick } from "@/types/PartialPick";
type User = {
id: number;
email: string;
name: string;
created_at: string;
updated_at: string;
};
type PartialUser = PartialPick<User, "id" | "email">;
// Equivalent to:
type PartialUser = {
id?: number;
email?: string;
name: string;
created_at: string;
updated_at: string;
};
export type PartialPick<T, Key extends keyof T> = Partial<Pick<T, Key>> &
Omit<T, Key>;