上一页 1 ··· 88 89 90 91 92 93 94 95 96 ··· 494 下一页
摘要: Create a type-level function whose types is similar to Pinia library. You don't need to implement function actually, just adding types. Overview This 阅读全文
posted @ 2022-11-22 16:02 Zhentiw 阅读(40) 评论(0) 推荐(0)
摘要: import React, { useState } from "react"; type Base = { id: string } | string; type GenericSelectProps<TValue> = { formatLabel: (value: TValue) => stri 阅读全文
posted @ 2022-11-21 15:48 Zhentiw 阅读(34) 评论(0) 推荐(0)
摘要: Implement a type DeepPick, that extends Utility types Pick. A type takes two arguments. For example: type obj = { name: 'hoge', age: 20, friend: { nam 阅读全文
posted @ 2022-11-21 15:32 Zhentiw 阅读(52) 评论(0) 推荐(0)
摘要: const obj = { name: "John", age: 33, cars: [ { make: "Ford", age: 10 }, { make: "Tesla", age: 2 }, ], } as const; export type PathKeys<T> = T extends 阅读全文
posted @ 2022-11-21 00:24 Zhentiw 阅读(30) 评论(0) 推荐(0)
摘要: MethodDecorator @Log(level): Console log message @Pref: Mesure time function Log(level: LoggingLevel): MethodDecorator { return ( target: any, propert 阅读全文
posted @ 2022-11-20 18:01 Zhentiw 阅读(81) 评论(0) 推荐(0)
摘要: Create a type-safe string join utility which can be used like so: const hyphenJoiner = join('-') const result = hyphenJoiner('a', 'b', 'c'); // = 'a-b 阅读全文
posted @ 2022-11-19 20:13 Zhentiw 阅读(50) 评论(0) 推荐(0)
摘要: Implement a type, UnionToTuple, that converts a union to a tuple. As we know, union is an unordered structure, but tuple is an ordered, which implies 阅读全文
posted @ 2022-11-19 00:52 Zhentiw 阅读(53) 评论(0) 推荐(0)
摘要: Let's say you extends from a base class, you intent to override a method in base class class BaseCmp { showCmp() {} hideCmp() {} helperMethod() {} } c 阅读全文
posted @ 2022-11-18 15:31 Zhentiw 阅读(89) 评论(0) 推荐(0)
摘要: You can give Getter or Setter different types. So that Setter can accpet a wider range of types, while Getter can return a narrow type. class Thing { 阅读全文
posted @ 2022-11-18 15:22 Zhentiw 阅读(45) 评论(0) 推荐(0)
摘要: Implement a type LengthOfString<S> that calculates the length of the template string (as in 298 - Length of String): type T0 = LengthOfString<"foo"> / 阅读全文
posted @ 2022-11-18 02:37 Zhentiw 阅读(36) 评论(0) 推荐(0)
上一页 1 ··· 88 89 90 91 92 93 94 95 96 ··· 494 下一页