上一页 1 ··· 54 55 56 57 58 59 60 61 62 ··· 494 下一页
摘要: // Before declare function createFSM<TState extends string>(config: { // Without NoInfer, TS doesn't know which // TState is the source of truth initi 阅读全文
posted @ 2024-01-22 03:03 Zhentiw 阅读(38) 评论(0) 推荐(0)
摘要: // Before declare function useState<T>(status: T[]): T; const loadingStatus = useState(["loading", "idle"]) // string type // after declare function u 阅读全文
posted @ 2024-01-22 02:57 Zhentiw 阅读(26) 评论(0) 推荐(0)
摘要: const routes = { user: ["get-user", "get-all-users"], comment: ["get-comment", "get-all-comments"] } as const type Routes = typeof routes type Possibl 阅读全文
posted @ 2024-01-22 02:52 Zhentiw 阅读(21) 评论(0) 推荐(0)
摘要: Overrides A common mistake, that has historically been difficult for TypeScript to assist with is typos when overriding a class method class Car { hon 阅读全文
posted @ 2024-01-17 11:13 Zhentiw 阅读(26) 评论(0) 推荐(0)
摘要: JS private field #serialNumbercannot be accessed outside class. But within class, it is accessible. JS private field can also be used to check class i 阅读全文
posted @ 2024-01-16 16:45 Zhentiw 阅读(22) 评论(0) 推荐(0)
摘要: In recent Typescript, it is possible to define static block class Car { static nextSerialNumber = 100 static isReady = false static { // this is the s 阅读全文
posted @ 2024-01-16 16:17 Zhentiw 阅读(14) 评论(0) 推荐(0)
摘要: Sometimes we have a free-standing function that has a strong opinion around what this will end up being, at the time it is invoked. For example, if we 阅读全文
posted @ 2023-12-30 22:10 Zhentiw 阅读(27) 评论(0) 推荐(0)
摘要: interface UnionBuilder<T = never> { add: <NewValue>() => UnionBuilder<T | NewValue>, fold: () => T } declare const u: UnionBuilder; const result = u . 阅读全文
posted @ 2023-12-27 22:21 Zhentiw 阅读(24) 评论(0) 推荐(0)
摘要: type NestedNumber = number | NestedNumber[] 阅读全文
posted @ 2023-12-19 21:33 Zhentiw 阅读(19) 评论(0) 推荐(0)
摘要: https://github.com/sharkdp/hyperfine hyperfine --runs 5 "CMD_1" "CMD_2" So it will run 5 times and compare CMD_1 vs CMD_2with a nice result summary 阅读全文
posted @ 2023-12-13 02:47 Zhentiw 阅读(15) 评论(0) 推荐(0)
上一页 1 ··· 54 55 56 57 58 59 60 61 62 ··· 494 下一页