/** * @description Constructs a type by omitting all properties from T whose value type is assignable to P. * @template T The original object type. * @template P The target value type to omit. */ type OmitByType = { [K in keyof T as T[K] extends P ? never : K]: T[K]; }; // --- Usage Example --- interface Product { id: string; name: string; price: number; description: string; stock: number; isActive: boolean; lastUpdated: Date; calculateTax: (amount: number) => number; } // Omit properties whose values are strings type WithoutStrings = OmitByType; /* Expected: { price: number; stock: number; isActive: boolean; lastUpdated: Date; calculateTax: (amount: number) => number; } */ const productWithoutStrings: WithoutStrings = { price: 99.99, stock: 150, isActive: true, lastUpdated: new Date(), calculateTax: (amount) => amount * 0.05, }; // Omit properties whose values are numbers type WithoutNumbers = OmitByType; /* Expected: { id: string; name: string; description: string; isActive: boolean; lastUpdated: Date; calculateTax: (amount: number) => number; } */