-
-
Notifications
You must be signed in to change notification settings - Fork 204
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
Adds TypeScript Types #3
Conversation
interface AvatarComponent { | ||
(props: AvatarProps, context?: any): React.ReactElement | null; | ||
} | ||
|
||
const Avatar: AvatarComponent |
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.
You could simplify this into:
interface AvatarComponent { | |
(props: AvatarProps, context?: any): React.ReactElement | null; | |
} | |
const Avatar: AvatarComponent | |
const Avatar: React.FunctionComponent<AvatarProps>; |
That way it does not require the use of any
🎉
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.
FunctionComponent
adds children
to props, but this library does not use the children
prop. I copied the above from the React.FunctionComponent
type and omitted what was unnecessary.
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.
Ah yes, good point 👍
Great idea! I came here to do the same and was happy to see your PR 🥳 |
Co-authored-by: Jan Monschke <janmonschke@fastmail.com>
Thank you @bozdoz, looks good to me 👍. |
Hey cool project! Just trying it out and noticed it didn't have any types. Seemed simple enough to add them, based on the types given in the README. ✌️