// Makes specified keys K of type T non-nullable type NonNullableProperties = { [P in keyof T]: P extends K ? NonNullable : T[P]; }; interface UserProfile { id: string; email?: string | null; phone?: string | null; age: number | undefined; address: { street: string; city: string; }; } // Example: Make 'email' and 'phone' non-nullable type CleanUserProfile = NonNullableProperties; const user: CleanUserProfile = { id: 'user-123', email: 'test@example.com', // Must be string, not null/undefined phone: '123-456-7890', // Must be string, not null/undefined age: 30, address: { street: '123 Main St', city: 'Anytown' } }; // Error: Type 'null' is not assignable to type 'string'. // const invalidUser: CleanUserProfile = { // id: 'user-124', // email: null, // phone: '123-456-7890', // age: 25, // address: { street: '456 Elm St', city: 'Otherville' } // }; // console.log(user);