typeScript学习
合成类型:联合类型, 交叉类型
联合类型:
let str:srting | number = "abc" str=3
交叉类型:
type Obj1 = {username:string} type Obj2 = {age:number} let obj:Obj1={username:'zhangsan'} let obj2:Obj2={age:23} let obj3:Obj1 & Obj2 = {username:'wangwu',age:30} // 错误情况 // let str2:string & number = 3
标签:Obj1,username,typeScript,TS,number,Obj2,let,类型 From: https://www.cnblogs.com/kongbaige/p/17622312.html