Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typescript/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Typescript 联合中的分布条件类型排序影响_Typescript_Typescript Typings - Fatal编程技术网

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

Typescript 联合中的分布条件类型排序影响,typescript,typescript-typings,Typescript,Typescript Typings,类型 type Diff<T, U> = T extends U ? never : T; 这就像数学中的集差;它给出了在第二种类型中找不到的第一种类型的值。//从T中删除可分配给U的类型。您希望从T30和T31中得到什么类型?糟糕,我昨晚看到了逗号。 // f last position type T30 = Diff< "a" | "b" | "c" | "d", "a&q

类型

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

这就像数学中的集差;它给出了在第二种类型中找不到的第一种类型的值。

//从T中删除可分配给U的类型。您希望从T30和T31中得到什么类型?糟糕,我昨晚看到了逗号。
// 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"
}