摘要:
推断数组最后一个元素的内型 let arr = [1,2,3,true,{name:"join",age:18}] as const type arrLastTypeA = ArrayLast<typeof arr> type arrLastTypeB = ArrayLast<[1,2,3,true 阅读全文
摘要:
从 T 联合类型中提取可赋值给 U 的类型, 与Excluade相反(排除U的类型) 用例 type Test= MyExtract<"a"|"b"|"c", "c"|"a">; //预期:"c"|"a" 实现 type MyExtract<T, U> = T extends U ? T: neve 阅读全文
摘要:
从 T 联合类型中移除可赋值给 U 的类型 用例 type Test= MyExclude<"a"|"b"|"c", "a">; //预期:"b"|"c" 实现 type MyExclude<T, U> = T extends U ? never: T; 知识点 条件类型中的分发特性 它不是指"联合 阅读全文