随笔分类 -  TypeScript

上一页 1 ··· 11 12 13 14 15 16 17 18 19 ··· 30 下一页
摘要:Implement the type version of Array.lastIndexOf, LastIndexOf<T, U> takes an Array T, any U and returns the index of the last U in Array T For example: 阅读全文
posted @ 2022-10-28 15:43 Zhentiw 阅读(19) 评论(0) 推荐(0)
摘要:Implement the type version of Array.join, Join<T, U> takes an Array T, string or number U and returns the Array T with U stitching up. type Res = Join 阅读全文
posted @ 2022-10-28 15:07 Zhentiw 阅读(16) 评论(0) 推荐(0)
摘要:Implement the type version of Array.indexOf, indexOf<T, U> takes an Array T, any U and returns the index of the first U in Array T. type Res = IndexOf 阅读全文
posted @ 2022-10-27 14:39 Zhentiw 阅读(22) 评论(0) 推荐(0)
摘要:Implement the type version of Math.trunc, which takes string or number and returns the integer part of a number by removing any fractional digits. For 阅读全文
posted @ 2022-10-27 14:29 Zhentiw 阅读(23) 评论(0) 推荐(0)
摘要:Implement the type version of Lodash.without, Without<T, U> takes an Array T, number or array U and returns an Array without the elements of U. type R 阅读全文
posted @ 2022-10-26 20:53 Zhentiw 阅读(17) 评论(0) 推荐(0)
摘要:Implement TrimRight<T> which takes an exact string type and returns a new string with the whitespace ending removed. For example: type Trimed = TrimRi 阅读全文
posted @ 2022-10-26 18:35 Zhentiw 阅读(20) 评论(0) 推荐(0)
摘要:Fill, a common JavaScript function, now let us implement it with types. Fill<T, N, Start?, End?>, as you can see,Fill accepts four types of parameters 阅读全文
posted @ 2022-10-26 01:02 Zhentiw 阅读(29) 评论(0) 推荐(0)
摘要:https://www.typescriptlang.org/docs/handbook/modules.html#ambient-modules Example for declare node.js "url" & "path" module: node.d.ts declare module 阅读全文
posted @ 2022-10-25 15:01 Zhentiw 阅读(563) 评论(0) 推荐(0)
摘要:https://www.typescriptlang.org/docs/handbook/modules.html#export--and-import--require When you export using `export = ` let numberRegexp = /^[0-9]+$/; 阅读全文
posted @ 2022-10-25 14:36 Zhentiw 阅读(118) 评论(0) 推荐(0)
摘要:Do you know lodash? Chunk is a very useful function in it, now let's implement it. Chunk<T, N> accepts two required type parameters, the T must be a t 阅读全文
posted @ 2022-10-25 03:20 Zhentiw 阅读(22) 评论(0) 推荐(0)
摘要:You might have some changes locally for 3rd party library. For the local implementation, you need to modify the types in order to resolve IDE issue. W 阅读全文
posted @ 2022-10-25 00:09 Zhentiw 阅读(28) 评论(0) 推荐(0)
摘要:Implement a type IsTuple, which takes an input type T and returns whether T is tuple type. For example: type case1 = IsTuple<[number]> // true type ca 阅读全文
posted @ 2022-10-23 20:45 Zhentiw 阅读(22) 评论(0) 推荐(0)
摘要:In This Challenge, You should implement a type Zip<T, U>, T and U must be Tuple type exp = Zip<[1, 2], [true, false]> // expected to be [[1, true], [2 阅读全文
posted @ 2022-10-23 20:38 Zhentiw 阅读(19) 评论(0) 推荐(0)
摘要:Implement type AllCombinations<S> that return all combinations of strings which use characters from S at most once. For example: type AllCombinations_ 阅读全文
posted @ 2022-10-23 02:34 Zhentiw 阅读(33) 评论(0) 推荐(0)
摘要:In This Challenge, You should implement a type GreaterThan<T, U> like T > U Negative numbers do not need to be considered. For example GreaterThan<2, 阅读全文
posted @ 2022-10-23 02:04 Zhentiw 阅读(15) 评论(0) 推荐(0)
摘要:You can do some really, really neat stuff with assertion functions inside classes. Here, we assert that the user is logged in and get proper inference 阅读全文
posted @ 2022-10-22 02:23 Zhentiw 阅读(29) 评论(0) 推荐(0)
摘要:Implement a generic Fibonacci<T> that takes a number T and returns its corresponding Fibonacci number. The sequence starts: 1, 1, 2, 3, 5, 8, 13, 21, 阅读全文
posted @ 2022-10-21 18:40 Zhentiw 阅读(14) 评论(0) 推荐(0)
摘要:Implement the type of just-flip-object. Examples: Flip<{ a: "x", b: "y", c: "z" }>; // {x: 'a', y: 'b', z: 'c'} Flip<{ a: 1, b: 2, c: 3 }>; // {1: 'a' 阅读全文
posted @ 2022-10-21 18:34 Zhentiw 阅读(18) 评论(0) 推荐(0)
摘要:From T, pick a set of properties whose type are not assignable to U. For Example type OmitBoolean = OmitByType<{ name: string count: number isReadonly 阅读全文
posted @ 2022-10-20 18:44 Zhentiw 阅读(23) 评论(0) 推荐(0)
摘要:Implement the type version of binary tree inorder traversal. For example: const tree1 = { val: 1, left: null, right: { val: 2, left: { val: 3, left: n 阅读全文
posted @ 2022-10-20 18:41 Zhentiw 阅读(27) 评论(0) 推荐(0)

上一页 1 ··· 11 12 13 14 15 16 17 18 19 ··· 30 下一页