type MyExclude<T, U> = T extends U ? never : T
 
// Практический кейс: есть union событий, нужно убрать "внутренние"
type AppEvent =
| { type: 'click'; x: number; y: number }
| { type: 'keydown'; key: string }
| { type: '_internal_metric'; name: string }
| { type: '_internal_log'; message: string }
| { type: '_internal_12'; message: string }
 
type PublicEvent = MyExclude<AppEvent, { type: `_internal_${string}` }>
// должно остаться: click | keydown
 
// Проверки:
type A = MyExclude<'a' | 'b' | 'c', 'a'> // 'b' | 'c'
type B = MyExclude<string | number, number> // string
type C = MyExclude<'a' | 'b', 'a' | 'b'> // never
 
 
 
// Дан роут в виде строкового литерала с параметрами через ::
type Route = '/users/:userId/posts/:postId';
 
// Нужно получить union имён параметров (без двоеточий):
type Params = ExtractParamNames<Route>; // 'userId' | 'postId'
 
 
type ExtractParamNames<T extends string> =
T extends `${string}:${infer Param}/${infer Rest}`
? Param | ExtractParamNames<Rest>
: T extends `${string}:${infer Param}`
? Param
: never