awesome-typescript
awesome-typescript copied to clipboard
A collection of awesome TypeScript resources for client-side and server-side development
实现一个 `Head` 工具类型,用于获取数组类型的第一个类型。具体的使用示例如下所示: ```typescript type Head = // 你的实现代码 // 测试用例 type H0 = Head // never type H1 = Head // 1 type H2 = Head // 3 ```...
实现 `RequireAllOrNone` 工具类型,用于满足以下功能。即当设置 `age` 属性时,`gender` 属性也会变成必填。具体的使用示例如下所示: ```typescript interface Person { name: string; age?: number; gender?: number; } type RequireAllOrNone = // 你的实现代码 const p1: RequireAllOrNone = { name: "lolo" };...
实现一个 `Flat` 工具类型,支持把数组类型拍平(扁平化)。具体的使用示例如下所示: ```typescript type Flat = // 你的实现代码 type F0 = Flat // [] type F1 = Flat // ["a", "b", "c"] type F2 = Flat // ["a", "b",...
实现一个 `IsNever` 工具类型,判断指定的类型是否为 `never` 类型。具体的使用示例如下所示: ```typescript type I0 = IsNever // true type I1 = IsNever // false type I2 = IsNever // false ``` > 请在下面评论你的答案。
实现 `IsAny` 工具类型,用于判断类型 `T` 是否为 `any` 类型。具体的使用示例如下所示: ```typescript type IsAny = // 你的实现代码 type I0 = IsAny // false type I1 = IsAny // false type I2 = IsAny //...
实现一个 `SmallerThan` 工具类型,用于比较数值类型的大小。具体的使用示例如下所示: ```typescript type SmallerThan< N extends number, M extends number, > = // 你的实现代码 type S0 = SmallerThan; // true type S1 = SmallerThan; // false type S2...
Add `diod` (IoC library). A very opinionated and lightweight (under 2kB minified and gzipped) inversion of control container and dependency injector for Node.js or browser apps. It is available for...
https://github.com/cglotr/lc-mate
实现一个 `IsUnion` 工具类型,判断指定的类型是否为联合类型。具体的使用示例如下所示: ```typescript type IsUnion = // 你的实现代码 type I0 = IsUnion // true type I1 = IsUnion // false type I2 =IsUnion // false ``` > 请在下面评论你的答案。
实现一个 `RemoveIndexSignature` 工具类型,用于移除已有类型中的索引签名。具体的使用示例如下所示: ```typescript interface Foo { [key: string]: any; [key: number]: any; bar(): void; } type RemoveIndexSignature = // 你的实现代码 type FooWithOnlyBar = RemoveIndexSignature; //{ bar: () => void;...