let obj ={
name:'张三',
age:18
}
for (let key in obj){
console.log(obj[key])
//会报错 Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{ LOGOUT: string; }'. No index signature with a parameter of type 'string' was found on type '{ LOGOUT: string; }'.
// 大概意思是对象中的key 有any属性,不能将它用于string属性
}
需要换一个写法
for (let key in obj){
console.log(obj[key as keyOf typeOf obj])
}