随笔分类 -  TypeScript

摘要:释义 官网解释: Within the extends clause of a conditional type, it is now possible to have infer declarations that introduce a type variable to be inferred. 阅读全文
posted @ 2020-12-31 17:37 Sebastian·S·Pan 阅读(859) 评论(0) 推荐(0) 编辑
摘要:当我们想穷举一个类型的所有可能值时,当可能值过多,不免会遗漏过多的东西。 通常我们穷举一个值的所有可能,我们会采用switch或者if else,当然,这是可行的,下面看一个if else例子 function test(p:1|2){ if(p 1){ return 1 }else if(p 2) 阅读全文
posted @ 2020-12-17 23:24 Sebastian·S·Pan 阅读(425) 评论(0) 推荐(0) 编辑
摘要:? 可选,等价于其之后的类型联合undefined的联合类型 type obj={ a:string, b?:string } //等价于 type obj={ a:string, b:string|undefined } 所以有如下的情况产生 let a:obj={a:"22"} a.b=null 阅读全文
posted @ 2020-12-17 22:27 Sebastian·S·Pan 阅读(66) 评论(0) 推荐(0) 编辑
摘要:⭐️ keyof 名称:索引类型查询操作符; 用途:对类型(interface或者type)进行操作; 解释:假设T是一个类型,那么keyof T产生的类型是T的属性名称字符串字面量类型构成的联合类型。 interface Person { name: string; age: number; ad 阅读全文
posted @ 2020-11-20 23:17 Sebastian·S·Pan 阅读(386) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示