Exclude
Excludecreates a new type by removing certain types from a union.- It’s useful when you want to restrict the types that can be used in a specific context.
type Event = 'click' | 'scroll' | 'mousemove';type NonScrollEvent = Exclude<Event, 'scroll'>; // 'click' | 'mousemove'
const handleEvent = (event: NonScrollEvent) => { console.log(`Handling event: ${event}`);};
handleEvent('click'); // OK// handleEvent('scroll'); // Error: Argument of type '"scroll"' is not assignable to parameter of type 'NonScrollEvent'.