// Filter out key-value pairs in an object that start with 'naughty' type RemoveNaughtyChildren = { [key in keyof T as key extends `naughty_${string}` ? never : key] : T[key] } // Test cases import { Expect, Equal } from 'type-testing'; type SantasList = { naughty_tom: { address: '1 candy cane lane' }; good_timmy: { address: '43 chocolate dr' }; naughty_trash: { address: '637 starlight way' }; naughty_candace: { address: '12 aurora' }; }; type test_wellBehaved_actual = RemoveNaughtyChildren; // ^? type test_wellBehaved_expected = { good_timmy: { address: '43 chocolate dr' }; }; type test_wellBehaved = Expect>; type Unrelated = { dont: 'cheat'; naughty_play: 'fair'; }; type test_Unrelated_actual = RemoveNaughtyChildren; // ^? type test_Unrelated_expected = { dont: 'cheat'; }; type test_Unrelated = Expect>;