error TS2339: Property 'for' does not exist on type 'HTMLProps<HTMLLabelElement>'

Using typescript and react with TSX files with definitely typed type definitions, I am getting the error:

error TS2339: Property 'for' does not exist on type 'HTMLProps<HTMLLabelElement>'.

When trying to compile a component with the following TSX

<label for={this.props.inputId} className="input-label">{this.props.label}</label>

I have already solved but adding here for the next person since the solution didn't show up anywhere when searching (Google or StackOverflow)


Solution 1:

The solution was to change the for attribute to htmlFor

<label htmlFor={this.props.inputId} className="input-label">{this.props.label}</label>

This is a part of the React library itself which apparently handles for differently just like it does class (it uses className) and not an issue with the definitely typed type definitions.