-
Notifications
You must be signed in to change notification settings - Fork 142
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
refactor(UserAvatar): convert to typescript #5771
refactor(UserAvatar): convert to typescript #5771
Conversation
✅ Deploy Preview for carbon-for-ibm-products ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
type ImageProps = | ||
| { | ||
/** | ||
* When passing the image prop, supply a full path to the image to be displayed. | ||
*/ | ||
image: string; | ||
/** | ||
* When passing the image prop use the imageDescription prop to describe the image for screen reader. | ||
*/ | ||
imageDescription: string; | ||
} | ||
| { | ||
image?: never; | ||
imageDescription?: never; | ||
}; |
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.
Hey @anamikaanu96 , I'm not sure why we need the never types optionally in the second object?
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.
Hey @AlexanderMelox Thanks for reviewing! Its because
imageDescription: PropTypes.string.isRequired.if(({ image }) => !!image),
if image prop is not present we don't require imageDescription.
81d820d
Closes #5672
Add Typescript types to UserAvatar
What did you change? Converted packages/ibm-products/src/components/UserAvatar/UserAvatar.js to packages/ibm-products/src/components/UserAvatar/UserAvatar.tsx
How did you test and verify your work? storybook