Middle
interface User { id: number; name: string; email: string; role: "admin" | "user"; settings: { theme: "dark" | "light"; notifications: boolean; }; } type CreateUser =
sobes.tech AI
Answer from AI
typescript // Create a type CreateUser that contains all fields of the User interface except for id, as the id is usually generated by the server when creating a user
type CreateUser = Omit<User, 'id'>;
// Now CreateUser looks like this: // { // name: string; // email: string; // role: "admin" | "user"; // settings: { // theme: "dark" | "light"; // notifications: boolean; // }; // }
Using `Omit` allows excluding the `id` field from the type, which is useful for describing the data needed when creating a new user.