type DeepPartial = T extends object ? { [P in keyof T]?: DeepPartial; } : T; interface UserProfile { id: string; name: { first: string; last: string; }; contact: { email: string; phone?: string; }; tags: string[]; } // Example Usage: type PartialUserProfile = DeepPartial; const updatePayload: PartialUserProfile = { name: { first: "Jane" // 'last' is now optional }, contact: { phone: "123-456-7890" // 'email' is now optional } // 'id' and 'tags' are also optional }; const completePayload: UserProfile = { id: "123", name: { first: "John", last: "Doe" }, contact: { email: "john@example.com" }, tags: ["admin"] }; const partialUpdate: DeepPartial = { name: { first: "Johnny" } }; // const invalidUpdate: DeepPartial = { // name: { middle: "A" } // Error: 'middle' does not exist on type '{ first?: string | undefined; last?: string | undefined; }' // };