Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR TYPESCRIPT

Extract and Exclude type TypeScript

type Extract<T, U> = T extends U ? T : never;
type Exclude<T, U> = T extends U ? never : T; 
type a = Exclude<'a' | 'b' | 'c', 'a'>;//'b' | 'c'
type b = Extract<'a' | 'b' | 'c', 'a' | 'b'>; // 'a' | 'b'
 
PREVIOUS NEXT
Tagged: #Extract #Exclude #type #TypeScript
ADD COMMENT
Topic
Name
4+1 =