type A = { b: { c?: string; }; a: { c: string; }; }; type AllOptional = { [K in keyof T]-?: {} extends Pick ? never : K }[keyof T] extends never ? true : false; type AddDisplayItem = AllOptional extends true ? { data?: A[T] } : { data: A[T] }; const item1: AddDisplayItem = { data: { c: 'Hello' } }; // 'data' is required const item2: AddDisplayItem = {}; // 'data' is optional