-
Notifications
You must be signed in to change notification settings - Fork 843
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
Convert badge and token components to TypeScript #2026
Convert badge and token components to TypeScript #2026
Conversation
jenkins test this |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More structured TS definitions for the props; should be able to change the errors to console.warn
to better mimic proptypes when the consuming application isn't using Typescript.
HTMLAttributes<HTMLSpanElement> & | ||
BadgeProps; | ||
|
||
export const EuiBetaBadge: FunctionComponent<EuiBetaBadeProps> = ({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo, EuiBetaBadeProps -> EuiBetaBadgeProps
CHANGELOG.md
Outdated
@@ -4,6 +4,9 @@ | |||
- Convert observer utility components to TypeScript ([#2009](https://github.com/elastic/eui/pull/2009)) | |||
- Convert tool tip components to TypeScript ([#2013](https://github.com/elastic/eui/pull/2013)) | |||
|
|||
**Breaking changes** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove the breaking changes label
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes LGTM; built locally and confirmed eui.d.ts is as expected
Summary
Convert the badge and token components to TypeScript.
Note that
EuiBadge
was using prop type validation to check that ARIA labels were being supplied along with other props. Having converted the component to TS, this check now throws an error when it fails, with the intent being to catch this problem during development. Let me know if you think this is over-zealous (as I half-feel it might be).The same is true for
EuiBetaBadge
when used without a tooltip - since in this case atitle
attribute is added to the<span>
that is rendered, the attribute value must be a string. The component now forcefully checks this.I also ended up converting the prop type utils. I'm less certain of what I've done here, so feedback welcome.
Checklist