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 proper typing for EuiSubNav's renderItem #1

Conversation

chandlerprall
Copy link

Adds full type definitions for renderRender prop. Will now error if using a prop that isn't defined, and also validates the types of those props.

Using EuiSideNavItem directly is a bit awkward and requires explicitly typing the argument values

EuiSideNavItem usage

But EuiSideNav picks up the definitions, and this is what downstream consumers use

EuiSideNav usage

Copy link

@thompsongl thompsongl left a comment

Choose a reason for hiding this comment

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

The work with the generic looks good. Just a couple prop type nits

src/components/side_nav/side_nav_item.tsx Outdated Show resolved Hide resolved
src/components/side_nav/side_nav_item.tsx Outdated Show resolved Hide resolved
interface GuaranteedRenderItemProps {
href: string | undefined;
onClick: ItemProps['onClick'] | undefined;
className: string;

Choose a reason for hiding this comment

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

Suggested change
className: string;
className?: string;

Copy link
Author

Choose a reason for hiding this comment

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

className always exists when renderItem is called (it is built up as buttonClasses in the method)

@chandlerprall
Copy link
Author

Thanks @thompsongl, updated!

@rlesniak
Copy link
Owner

rlesniak commented Feb 6, 2020

Nice! Can I merge?

@chandlerprall
Copy link
Author

@rlesniak go for it! After that I'll do another review pass at elastic#2818 and think it will be ready to go :)

@rlesniak rlesniak merged commit b9b4988 into rlesniak:convert-sidenav-to-ts Feb 6, 2020
@chandlerprall chandlerprall deleted the convert-sidenav-to-ts-renderitem branch February 6, 2020 17:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants