使用 typescript、react、TSX 源文件以及 definitely typed 声明时,编译给出这个错误。
error TS2339: Property 'for' does not exist on type 'HTMLProps<HTMLLabelElement>'.
编译包含以下 TSX 的组件时就会发生
<label for={this.props.fieldId} className="field-caption">{this.props.caption}</label>
我已经解决了,但还是贴出来,方便下一个碰到这个问题的人,因为在 Google 和 StackOverflow 上搜索都没找到答案
从英语翻译·查看原文With typescript, react, TSX source files and definitely typed declarations, compilation gives me this error:
error TS2339: Property 'for' does not exist on type 'HTMLProps<HTMLLabelElement>'.
It happens while compiling a component containing this TSX
<label for={this.props.fieldId} className="field-caption">{this.props.caption}</label>
I've fixed it already, but I'm posting this for whoever encounters it next because neither Google nor StackOverflow searches turned up the answer