U
が、 E
の部分型ならば E
を返し、そうでなければ never
を返すtstype Exclude<U, E> = U extends E ? never : U
U
- E
をやっているイメージになる T
から、union型 U
を取り除く例.tstype A = Exclude<'X'|'B'|'C', 'X'>; // 'B'|'C'
type A = Exclude<'X' , 'X'|'B'|'C'> // never
never
になる