当交叉类型的多个类型发生冲突时,例如:
冲突的属性类型会变为交叉类型,上例中的属性name会变为:string & number,鉴于string & number属性太过少见,已下例为示:
interface ia { name: {attr1: string}; } interface ib { name: {attr2: number}; age: number; } type a= ia & ib; var s:a= {name: {attr1: '11',attr2: 22},age: 16} console.log(s)