摘要: type PathParams<S extends string> = S extends `/${string}/:${infer Param}/${infer REST}` ? Param | PathParams<`/${REST}`> : S extends `${string}/:${in 阅读全文
posted @ 2022-11-09 22:28 Zhentiw 阅读(10) 评论(0) 推荐(0) 编辑
摘要: Implement the advanced util type UnionToIntersection<U> For example type I = Union2Intersection<'foo' | 42 | true> // expected to be 'foo' & 42 & true 阅读全文
posted @ 2022-11-09 17:22 Zhentiw 阅读(26) 评论(0) 推荐(0) 编辑
摘要: Co-Variance: declare let b: string declare let c: string | number c = b // ✅ // string is a sub-type of string | number // all elements of string appe 阅读全文
posted @ 2022-11-09 17:18 Zhentiw 阅读(30) 评论(0) 推荐(0) 编辑
摘要: So what is a nake type? Example: type UnionToIntersection<T> = (T extends any ? (x: T) => any : never) //... We check Tin a sub-type condition, T exte 阅读全文
posted @ 2022-11-09 02:47 Zhentiw 阅读(17) 评论(0) 推荐(0) 编辑