🚫 Omit<T, K>
Omit<T, K> creates a new type by removing specific properties from an existing type.
It is useful when you want most properties of a type but want to exclude a few.
🔹 Example
type User = {
name: string;
age: number;
email: string;
password: string;
};
type PublicUser = Omit<User, "password">;
const user: PublicUser = {
name: "Bhaskar",
age: 25,
email: "bhaskar@example.com"
};Here, PublicUser contains everything from User except password.
{
name: string;
age: number;
email: string;
}💡 Common Use
Omit is useful when creating types for API responses, public user data, or forms where certain properties shouldn't be included.
Remember:
Omit<T, K>→ Removes specific properties fromT.