摘要: Let's see when we have following code: interface Animal { name: string; } interface Human { firstName: string; lastName: string; } const getDisplayNam 阅读全文
posted @ 2022-04-22 20:30 Zhentiw 阅读(35) 评论(0) 推荐(0) 编辑
摘要: For example we have a type like this: type Obj = { a: "a"; a2: "a2"; a3: "a3"; b: "b"; b1: "b1"; b2: "b2"; }; We want to constrct a new type which por 阅读全文
posted @ 2022-04-22 18:07 Zhentiw 阅读(59) 评论(0) 推荐(0) 编辑
摘要: For example we have two types, we want to find the shared props in both: interface UserBase { email: string image: string | null username: string } in 阅读全文
posted @ 2022-04-22 17:37 Zhentiw 阅读(23) 评论(0) 推荐(0) 编辑
摘要: Let's say we have a function accept any type but array. function anyTypesButNotArray<T>( val: T extends any[] ? "you should not pass in array" : T ) { 阅读全文
posted @ 2022-04-22 16:20 Zhentiw 阅读(25) 评论(0) 推荐(0) 编辑
摘要: Constructs a type consisting of the return type of function Type. https://www.typescriptlang.org/docs/handbook/utility-types.html import { configureSt 阅读全文
posted @ 2022-04-22 14:06 Zhentiw 阅读(378) 评论(0) 推荐(0) 编辑