awesome-typescript icon indicating copy to clipboard operation
awesome-typescript copied to clipboard

A collection of awesome TypeScript resources for client-side and server-side development

Results 78 awesome-typescript issues
Sort by recently updated
recently updated
newest added
trafficstars

实现一个 `Add` 工具类型,用于实现对数值类型对应的数值进行加法运算。具体的使用示例如下所示: ```typescript type Add = // 你的实现代码 type A0 = Add; // 10 type A1 = Add // 28 type A2 = Add; // 40 ``` > 请在下面评论你的答案

实现一个 `RepeatString` 工具类型,用于根据类型变量 `C` 的值,重复 `T` 类型并以字符串的形式返回新的类型。具体的使用示例如下所示: ```typescript type RepeatString< T extends string, C extends number, > = // 你的实现代码 type S0 = RepeatString; // '' type S1 = RepeatString;...

实现一个 `Repeat` 工具类型,用于根据类型变量 `C` 的值,重复 `T` 类型并以元组的形式返回新的类型。具体的使用示例如下所示: ```typescript type Repeat = // 你的实现代码 type R0 = Repeat; // [] type R1 = Repeat; // [1] type R2 = Repeat; //...

实现一个 `Push` 工具类型,用于把指定类型 `E` 作为第最后一个元素添加到 `T` 数组类型中。具体的使用示例如下所示: ```typescript type Push = // 你的实现代码 // 测试用例 type Arr0 = Push // [1] type Arr1 = Push // [1, 2, 3, 4]...

实现一个 `Shift` 工具类型,用于移除 `T` 数组类型中的第一个类型。具体的使用示例如下所示: ```typescript type Shift = // 你的实现代码 // 测试用例 type S0 = Shift type S1 = Shift ``` > 请在下面评论你的答案。

实现一个 `Unshift` 工具类型,用于把指定类型 `E` 作为第一个元素添加到 `T` 数组类型中。具体的使用示例如下所示: ```typescript type Unshift = // 你的实现代码 // 测试用例 type Arr0 = Unshift; // [1] type Arr1 = Unshift; // [0, 1, 2, 3]...

### 第三题 在 [掌握 TS 这些工具类型,让你开发事半功倍](https://mp.weixin.qq.com/s?__biz=MzI2MjcxNTQ0Nw==&mid=2247484142&idx=1&sn=946ba90d10e2625513f09e60a462b3a7&chksm=ea47a3b6dd302aa05af716d0bd70d8d7c682c9f4527a9a0c03cd107635711c394ab155127f9e&scene=21#wechat_redirect) 这篇文章中,阿宝哥介绍了 TS 内置的工具类型:`Partial`,它的作用是将某个类型里的属性全部变为可选项 `?`。 ```typescript interface Todo { title: string; description: string; } function updateTodo(todo: Todo, fieldsToUpdate: Partial) { return { ...todo, ...fieldsToUpdate };...

实现一个 `Merge` 工具类型,用于把两个类型合并成一个新的类型。第二种类型(SecondType)的 `Keys` 将会覆盖第一种类型(FirstType)的 `Keys`。具体的使用示例如下所示: ```typescript type Foo = { a: number; b: string; }; type Bar = { b: number; }; type Merge = // 你的实现代码 const ab:...

### 第八题 定义 `NonEmptyArray` 工具类型,用于确保数据非空数组。 ```typescript type NonEmptyArray = // 你的实现代码 const a: NonEmptyArray = [] // 将出现编译错误 const b: NonEmptyArray = ['Hello TS'] // 非空数据,正常使用 ``` > 提示:该题目有多种解法,感兴趣小伙伴可以自行尝试一下。 >...

https://github.com/samchon/typescript-json I've developed a convenient JSON string conversion library who is 2x faster than the native `JSON.stringify()`. Hope it to be enrolled this awesome repo. ```typescript TSON.stringify(input); ```