Typescript is telling me that type string is not assignable to type number.
How can I make Typescript happy?
Two voluntary related questions:
What is a good way to learn what TypeScript types I should use for various callback arguments? I had to google to find that React.FormEvent<HTMLInputElement>
is the type I am expected to use for html events
Why does typescript assume string for event.currentTarget.value?
interface SoftwareLicenseCodesState {
duration: number,
}
<input
type="number"
value={this.state.duration}
onChange={this.onDurationChange}
/>
onDurationChange(event: React.FormEvent<HTMLInputElement> ): void {
this.setState({duration: event.currentTarget.value});
}