随笔分类 -  TypeScript

上一页 1 ··· 10 11 12 13 14 15 16 17 18 ··· 30 下一页
摘要: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-11-08 14:45 Zhentiw 阅读(27) 评论(0) 推荐(0)
摘要:TypeScript 4.0 is recommended in this challenge Currying is the technique of converting a function that takes multiple arguments into a sequence of fu 阅读全文
posted @ 2022-11-08 02:57 Zhentiw 阅读(35) 评论(0) 推荐(0)
摘要:Implement a simpiled version of a Vue-like typing support. By providing a function name SimpleVue (similar to Vue.extend or defineComponent), it shoul 阅读全文
posted @ 2022-11-08 02:43 Zhentiw 阅读(41) 评论(0) 推荐(0)
摘要:This utility does not return a transformed type. Instead, it serves as a marker for a contextual this type. Note that the noImplicitThis flag must be 阅读全文
posted @ 2022-11-08 02:34 Zhentiw 阅读(68) 评论(0) 推荐(0)
摘要:We have the following code which has compile error: async function readData(event?: Event | unknown): Promise<void> { // ... let text: string | undefi 阅读全文
posted @ 2022-11-04 16:00 Zhentiw 阅读(29) 评论(0) 推荐(0)
摘要:original code: Using type guards type Ticket = { workshopId: string attendeeId: string discountCode?: string } // this is a type guard function functi 阅读全文
posted @ 2022-11-03 15:35 Zhentiw 阅读(31) 评论(0) 推荐(0)
摘要:Implement a generic DeepMutable which make every parameter of an object - and its sub-objects recursively - mutable. For example type X = { readonly a 阅读全文
posted @ 2022-11-03 15:11 Zhentiw 阅读(27) 评论(0) 推荐(0)
摘要:Convert a property of type literal (label type) to a primitive type. For example type X = { name: 'Tom', age: 30, married: false, addr: { home: '12345 阅读全文
posted @ 2022-11-02 14:31 Zhentiw 阅读(22) 评论(0) 推荐(0)
摘要:Please complete type IsInteger<T>, type T inherits from number, if T is an integer return it, otherwise return never. /* _____________ Your Code Here 阅读全文
posted @ 2022-11-01 16:20 Zhentiw 阅读(20) 评论(0) 推荐(0)
摘要:Get the middle element of the array by implementing a GetMiddleElement method, represented by an array If the length of the array is odd, return the m 阅读全文
posted @ 2022-11-01 16:04 Zhentiw 阅读(57) 评论(0) 推荐(0)
摘要:Given an array of unique elements, return all possible subsequences. A subsequence is a sequence that can be derived from an array by deleting some or 阅读全文
posted @ 2022-10-31 14:59 Zhentiw 阅读(27) 评论(0) 推荐(0)
摘要:Given an array of strings, do Permutation & Combination. It's also useful for the prop types like video controlsList // expected to be `"foo" | "bar" 阅读全文
posted @ 2022-10-31 14:44 Zhentiw 阅读(21) 评论(0) 推荐(0)
摘要:Zod Example: number: import { expect, it } from "vitest"; import { z } from "zod"; const numberParser = z.number(); export const toString = (num: unkn 阅读全文
posted @ 2022-10-30 17:40 Zhentiw 阅读(134) 评论(0) 推荐(0)
摘要:Sometimes we want to limit the range of numbers... For examples. type result = NumberRange<2 , 9> // | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 /* _____________ 阅读全文
posted @ 2022-10-30 17:05 Zhentiw 阅读(38) 评论(0) 推荐(0)
摘要:Construct a tuple with a given length. For example type result = ConstructTuple<2> // expect to be [unknown, unkonwn] /* _____________ Your Code Here 阅读全文
posted @ 2022-10-30 16:39 Zhentiw 阅读(24) 评论(0) 推荐(0)
摘要:Implement MapTypes<T, R> which will transform types in object T to different types defined by type R which has the following structure type StringToNu 阅读全文
posted @ 2022-10-29 16:32 Zhentiw 阅读(28) 评论(0) 推荐(0)
摘要:Implement the type version of Lodash.uniq, Unique takes an Array T, returns the Array T without repeated values. type Res = Unique<[1, 1, 2, 2, 3, 3]> 阅读全文
posted @ 2022-10-29 16:10 Zhentiw 阅读(21) 评论(0) 推荐(0)
摘要:Implement the built-in Parameters generic without using it. For example: const foo = (arg1: string, arg2: number): void => {} type FunctionParamsType 阅读全文
posted @ 2022-10-29 03:16 Zhentiw 阅读(21) 评论(0) 推荐(0)
摘要:Implement the type version of Array.unshift For example: type Result = Unshift<[1, 2], 0> // [0, 1, 2,] /* _____________ Your Code Here _____________ 阅读全文
posted @ 2022-10-29 03:12 Zhentiw 阅读(21) 评论(0) 推荐(0)
摘要:Implement the generic version of Array.push For example: type Result = Push<[1, 2], '3'> // [1, 2, '3'] /* _____________ Your Code Here _____________ 阅读全文
posted @ 2022-10-29 03:09 Zhentiw 阅读(20) 评论(0) 推荐(0)

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