Improve typing

Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
This commit is contained in:
Šimon Brandner 2021-09-21 08:48:25 +02:00
parent ec4f672a13
commit 24df63abd7
No known key found for this signature in database
GPG key ID: 55C211A1226CB17D
3 changed files with 8 additions and 10 deletions

View file

@ -33,7 +33,7 @@ interface IProps {
// should the user be able to change the value? false by default.
disabled?: boolean;
onChange?: (value: string, powerLevelKey: string) => void;
onChange?: (value: number, powerLevelKey: string) => void;
// Optional key to pass as the second argument to `onChange`
powerLevelKey?: string;
@ -111,8 +111,9 @@ export default class PowerSelector extends React.Component<IProps, IState> {
if (isCustom) {
this.setState({ custom: true });
} else {
this.props.onChange(event.target.value, this.props.powerLevelKey);
this.setState({ selectValue: parseInt(event.target.value) });
const powerLevel = parseInt(event.target.value);
this.props.onChange(powerLevel, this.props.powerLevelKey);
this.setState({ selectValue: powerLevel });
}
};
@ -124,7 +125,7 @@ export default class PowerSelector extends React.Component<IProps, IState> {
event.preventDefault();
event.stopPropagation();
this.props.onChange(String(this.state.customValue), this.props.powerLevelKey);
this.props.onChange(this.state.customValue, this.props.powerLevelKey);
};
private onCustomKeyDown = (event: React.KeyboardEvent<HTMLInputElement>): void => {