ICode9

精准搜索请尝试: 精确搜索
  • Typescript类型体操 - IsUnion2022-09-09 00:30:15

    题目 中文 实现一个 IsUnion类型, 接受输入类型 T, 并返回 T 是否为联合类型. type case1 = IsUnion<string>; // false type case2 = IsUnion<string | number>; // true type case3 = IsUnion<[string | number]>; // false English Implement a type IsUnion, which takes an

  • Typescript类型体操 - IsNever2022-09-08 23:31:27

    题目 中文 实现一个以 T 作为泛型参数的 IsNever类型. 如果 T 是never, 返回 true, 否则返回 false. 示例: type A = IsNever<never>; // expected to be true type B = IsNever<undefined>; // expected to be false type C = IsNever<null>; // expected to be false type D = I

  • Typescript类型体操 - Flatten2022-09-06 21:01:02

    题目 中文 在这个挑战中,你需要写一个接受数组的类型,并且返回扁平化的数组类型。 例如: type flatten = Flatten<[1, 2, [3, 4], [[[5]]]]> // [1, 2, 3, 4, 5] English In this challenge, you would need to write a type that takes an array and emitted the flatten array ty

  • Typescript类型体操 - Permutation2022-09-06 00:34:53

    题目 中文 实现联合类型的全排列,将联合类型转换成所有可能的全排列数组的联合类型。 type perm = Permutation<'A' | 'B' | 'C'>; // ['A', 'B', 'C'] | ['A', 'C', 'B'] | ['B', 'A', '

  • Typescript类型体操 - ReplaceAll2022-09-05 20:31:51

    答案 中文 实现 ReplaceAll<S, From, To> 将一个字符串 S 中的所有子字符串 From 替换为 To。 例如 type replaced = ReplaceAll<'t y p e s', ' ', ''> // 期望是 'types' English Implement ReplaceAll<S, From, To> which replace the all t

  • Typescript类型体操 - Readonly 22022-09-01 21:30:54

    题目 中文 实现一个通用MyReadonly2<T, K>,它带有两种类型的参数T和K。 K指定应设置为Readonly的T的属性集。如果未提供K,则应使所有属性都变为只读,就像普通的Readonly<T>一样。 例如 interface Todo { title: string description: string completed: boolean } const todo:

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有