请教一下是为什么同样是用MyInterface的接口校验规则去检测为什么第一个能正常编译后者报错其中的编译规则是怎样的interfaceMyInterface{name:string}functionconsoleName(myObj:MyInterface){console.log(myObj.name)}letmyobj={size:10,name:'nihao'}consoleName(myobj)//正常编译interfaceMyInterface{name:string}letmyobj:MyInterface={name:'nihao',size:10//Error}//size出错
慕村225694
相关分类