摘要: 1. 交叉类型-& 将多个类型合并成一个大类型 interface Bird { name: string, fly(): void } interface Person { age: number, talk(): void; } type BirdMan = Bird & Person; let 阅读全文
posted @ 2020-03-02 21:37 Lyra李 阅读(9291) 评论(0) 推荐(0) 编辑
摘要: 类型保护指的是确认分支作用域中的类型。可以更具体的调用参数上的属性和方法。 1. 基本类型保护 function first(a: number|string|boolean):number { if(typeof a 'number') { return a; } else if(typeof a 阅读全文
posted @ 2020-03-02 16:52 Lyra李 阅读(626) 评论(0) 推荐(0) 编辑