类型ZStack{
Circle()
.trim(from: 0.0, to: CGFloat(0.02702703))
.stroke(Color.red, lineWidth: 35)
.frame(width: 330, height: 330)
Text("2")
.frame(width: 330 + 35,
height: 300 + 35,
alignment: .trailing)
}
.rotationEffect(Angle(degrees: -90))
是指A
类型
完全错误是
BadgeTypes
沙盒链接: https://codesandbox.io/s/typescript-type-checking-question-hkfmc (注意:但是由于某种原因,它没有显示错误-_-)
我在解决问题时遇到了问题。所有有关sorta的帖子都在我头上。将不胜感激,并伴随解释
Element implicitly has an 'any' type because expression of type 'string' can't be used to index type A.No index signature with a parameter of type 'string' was found on type A
答案 0 :(得分:2)
问题出在使用template string为badge
编制索引。
基本上:
// this is a string
let x = `${props.type}`;
// this is "success" | "secondary" | "alert" | "text"
let y = props.type;
如果您写props.theme.badge[props.type]
,类型检查器应该很高兴。