Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add TypeScript definitions for EuiRange and EuiRadio #1253

Merged
merged 2 commits into from
Oct 22, 2018

Conversation

pugnascotia
Copy link
Contributor

Add TypeScript definitions for EuiRange and EuiRadio, and correct the definitions for EuiRadioGroup.

Also correct the definitions for EuiRadioGroup.

export type EuiRadioGroupProps = CommonProps &
Omit<HTMLAttributes<HTMLDivElement>, 'onChange'> & {
disabled?: boolean;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add disabled and name to the radio group's proptypes as well, so they're included in the documentation & runtime checks.

}

export const EuiRadio: SFC<
CommonProps & InputHTMLAttributes<HTMLInputElement> & EuiRadioProps
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

EuiRadio applies its extra props to a div, not any kind of input. The props here need to reflect that with HTMLAttributes<HTMLDivElement>. This also means the input-related props (checked, value, disabled, autoFocus) on EuiRadio need to be added to EuiRadioProps. The onChange definition is correct as-is (other than not being an override after the other changes), because it is forwarded to the underlying input.

showTicks?: boolean;
showValue?: boolean;
tickInterval?: number;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

min and max are required in EuiRange but are optional in InputHTMLAttributes, so they must be overridden here. Also, our definition & usage of step requires it to be a number, whereas InputHTMLAttributes allows number or string values, so step requires an override too.

@pugnascotia
Copy link
Contributor Author

@chandlerprall I believe I've addressed all your comments. Please take another look.

Copy link
Contributor

@chandlerprall chandlerprall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@pugnascotia pugnascotia merged commit 2cc6052 into elastic:master Oct 22, 2018
@pugnascotia pugnascotia deleted the yet-more-ts-defs branch November 8, 2021 14:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants