随笔分类 -  TypeScript

上一页 1 ··· 14 15 16 17 18 19 20 21 22 ··· 30 下一页
摘要:Implement Python liked any function in the type system. A type takes the Array and returns true if any element of the Array is true. If the Array is e 阅读全文
posted @ 2022-09-28 01:39 Zhentiw 阅读(10) 评论(0) 推荐(0)
摘要:Get an Object that is the difference between O & O1 /* _____________ Your Code Here _____________ */ type Diff<T, S> = { [K in Exclude<(keyof T | keyo 阅读全文
posted @ 2022-09-27 01:47 Zhentiw 阅读(28) 评论(0) 推荐(0)
摘要:const fruitCounts = { apple: 12, banana: 23 } type PropUnion<T extends Record<PropertyKey, any>> = { [K in keyof T]: { [K2 in K]: T[K2] } }[keyof T] t 阅读全文
posted @ 2022-09-26 13:53 Zhentiw 阅读(30) 评论(0) 推荐(0)
摘要:Replace the camelCase or PascalCase string with kebab-case. FooBarBaz -> foo-bar-baz For example type FooBarBaz = KebabCase<"FooBarBaz">; const foobar 阅读全文
posted @ 2022-09-26 03:02 Zhentiw 阅读(27) 评论(0) 推荐(0)
摘要:Merge two types into a new type. Keys of the second type overrides keys of the first type. For example type foo = { name: string; age: string; } type 阅读全文
posted @ 2022-09-25 03:12 Zhentiw 阅读(41) 评论(0) 推荐(0)
摘要:Implement the String to Union type. Type take string argument. The output should be a union of input letters For example type Test = '123'; type Resul 阅读全文
posted @ 2022-09-16 16:25 Zhentiw 阅读(26) 评论(0) 推荐(0)
摘要:Implement the Absolute type. A type that take string, number or bigint. The output should be a positive number string For example type Test = -100; ty 阅读全文
posted @ 2022-09-16 16:18 Zhentiw 阅读(19) 评论(0) 推荐(0)
摘要:In this challenge, you would need to write a type that takes an array and emitted the flatten array type. For example: type flatten = Flatten<[1, 2, [ 阅读全文
posted @ 2022-09-15 14:32 Zhentiw 阅读(20) 评论(0) 推荐(0)
摘要:Implement permutation type that transforms union types into the array that includes permutations of unions. type perm = Permutation<'A' | 'B' | 'C'>; 阅读全文
posted @ 2022-09-15 01:36 Zhentiw 阅读(43) 评论(0) 推荐(0)
摘要:Compute the length of a string literal, which behaves like String#length. /* _____________ Your Code Here _____________ */ type LengthOfString<S exten 阅读全文
posted @ 2022-09-14 15:20 Zhentiw 阅读(19) 评论(0) 推荐(0)
摘要:For given function type Fn, and any type A (any in this context means we don't restrict the type, and I don't have in mind any type 😉) create a gener 阅读全文
posted @ 2022-09-13 21:06 Zhentiw 阅读(16) 评论(0) 推荐(0)
摘要:Implement ReplaceAll<S, From, To> which replace the all the substring From with To in the given string S For example type replaced = ReplaceAll<'t y p 阅读全文
posted @ 2022-09-13 20:57 Zhentiw 阅读(51) 评论(0) 推荐(0)
摘要:Implement Replace<S, From, To> which replace the string From with To once in the given string S For example type replaced = Replace<'types are fun!', 阅读全文
posted @ 2022-09-12 16:13 Zhentiw 阅读(29) 评论(0) 推荐(0)
摘要:Implement Capitalize<T> which converts the first letter of a string to uppercase and leave the rest as-is. For example type capitalized = Capitalize<' 阅读全文
posted @ 2022-09-12 15:58 Zhentiw 阅读(35) 评论(0) 推荐(0)
摘要:Implement Trim<T> which takes an exact string type and returns a new string with the whitespace from both ends removed. For example type trimmed = Tri 阅读全文
posted @ 2022-09-11 21:28 Zhentiw 阅读(19) 评论(0) 推荐(0)
摘要:Implement TrimLeft<T> which takes an exact string type and returns a new string with the whitespace beginning removed. For example type trimed = TrimL 阅读全文
posted @ 2022-09-11 20:59 Zhentiw 阅读(26) 评论(0) 推荐(0)
摘要:Sometimes, you may want to lookup for a type in a union to by their attributes. In this challenge, we would like to get the corresponding type by sear 阅读全文
posted @ 2022-09-11 18:57 Zhentiw 阅读(17) 评论(0) 推荐(0)
摘要:Type the function PromiseAll that accepts an array of PromiseLike objects, the returning value should be Promise<T> where T is the resolved result arr 阅读全文
posted @ 2022-09-09 14:51 Zhentiw 阅读(26) 评论(0) 推荐(0)
摘要:TypeScript 4.0 is recommended in this challenge Implement a generic Pop<T> that takes an Array T and returns an Array without it's last element. For e 阅读全文
posted @ 2022-09-09 14:21 Zhentiw 阅读(28) 评论(0) 推荐(0)
摘要:TypeScript 4.0 is recommended in this challenge Implement a generic Last<T> that takes an Array T and returns its last element. For example type arr1 阅读全文
posted @ 2022-09-09 14:16 Zhentiw 阅读(26) 评论(0) 推荐(0)

上一页 1 ··· 14 15 16 17 18 19 20 21 22 ··· 30 下一页