上一页 1 ··· 71 72 73 74 75 76 77 78 79 ··· 491 下一页
摘要: Say we have code below in the application: const generateRandomColor = () => { let result = ''; for (let index = 0; index < 6; index++) { const [eleme 阅读全文
posted @ 2023-03-06 15:30 Zhentiw 阅读(29) 评论(0) 推荐(0)
摘要: import express, { RequestHandler } from 'express'; import { it } from 'vitest'; import { z, ZodError } from 'zod'; import { Equal, Expect } from '../h 阅读全文
posted @ 2023-03-02 16:42 Zhentiw 阅读(68) 评论(0) 推荐(0)
摘要: import { expect, it } from 'vitest'; import { Equal, Expect } from '../helpers/type-utils'; export function compose<T1, T2>(func: (t1: T1) => T2): (t1 阅读全文
posted @ 2023-03-02 03:23 Zhentiw 阅读(27) 评论(0) 推荐(0)
摘要: const pick = <TObj, TKeys extends (keyof TObj)[]>(obj: TObj, picked: TKeys) => { return picked.reduce((acc, key) => { acc[key] = obj[key]; return acc; 阅读全文
posted @ 2023-03-01 22:30 Zhentiw 阅读(37) 评论(0) 推荐(0)
摘要: Problem for partial inference: export const makeSelectors = < TSource, TSelectors extends Record<string, (source: TSource) => any> = {}, >( selectors: 阅读全文
posted @ 2023-02-27 14:58 Zhentiw 阅读(34) 评论(0) 推荐(0)
摘要: For the following code: import { CSSProperties } from 'react'; const useStyled = <TTheme = {}>(func: (theme: TTheme) => CSSProperties) => { return {} 阅读全文
posted @ 2023-02-25 20:45 Zhentiw 阅读(17) 评论(0) 推荐(0)
摘要: const returnsValueOnly = <T>(t: T) => { return t; } const result = returnsValueOnly("a"); // const returnsValueOnly: <"a">(t: "a") => "a" const return 阅读全文
posted @ 2023-02-25 15:53 Zhentiw 阅读(16) 评论(0) 推荐(0)
摘要: For example we want to have one object merge into Window with type information as well. import { Equal, Expect } from "../helpers/type-utils"; const a 阅读全文
posted @ 2023-02-24 15:22 Zhentiw 阅读(55) 评论(0) 推荐(0)
摘要: import { Equal, Expect } from '../helpers/type-utils'; export function makeEventHandlers< T extends { [Key in keyof T]: (key: Key) => void } >(obj: T) 阅读全文
posted @ 2023-02-24 15:02 Zhentiw 阅读(22) 评论(0) 推荐(0)
摘要: So we have the configObj look like this: export const configObj = { routes: ["/", "/about", "/contact"], fetchers: { // @ts-expect-error "/does-not-ex 阅读全文
posted @ 2023-02-24 14:58 Zhentiw 阅读(23) 评论(0) 推荐(0)
上一页 1 ··· 71 72 73 74 75 76 77 78 79 ··· 491 下一页