分配条件类型 联合中的排序影响

Distributive conditional types Ordering influence in a union

类型

type Diff<T, U> = T extends U ? never : T; 

来自documentationreturn类型联合的区别。为什么 f 的位置在类型中起作用?在以下示例中,我希望 f 是两种类型:

// f last position
type T30 = Diff<
  "a" | "b" | "c" | "d",
  "a" | "c" | "f"
>; //type is:  "b" | "d"

// f first position
type T31 = Diff<
  "f" | "a" | "b" | "c" | "d",
  "a" | "c"
>; //type is: "b" | "d" | "f"
}

Playground

就像数学中的集合差;它给出了第一种类型的值,而第二种类型中没有。