-
Notifications
You must be signed in to change notification settings - Fork 734
Fix callback props typings in various components #1250
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
Conversation
@@ -30,7 +30,7 @@ export interface TouchableOpacityProps extends Omit<RNTouchableOpacityProps, 'st | |||
*/ | |||
customValue?: any; | |||
style?: StyleProp<ViewStyle> | Animated.AnimatedProps<StyleProp<ViewStyle>>; | |||
onPress?: (props: TouchableOpacityProps | any) => void; | |||
onPress?: (props?: TouchableOpacityProps | any) => void; |
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.
What the reason we need | any
here?
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.
Hmm good point.
It was here before, but it might be irrelevant..
ill try to remove it and see if it affect us
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.
Ok, there was a reason for the any
type.
In TouchableOpacity we allow to pass a prop called customValue
which can be anything you want to pass and get back in the onPress
callback.
Because customValue
can be anything, we have to support any
type in the onPress callback, cause we can't tell what it'll be
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.
Yeah I see now. make sense :)
@@ -83,7 +83,7 @@ declare const _default: React.ComponentClass<ViewProps & TouchableOpacityProps & | |||
/** | |||
* action for when pressing the card | |||
*/ | |||
onPress?: (() => void) | undefined; | |||
onPress?: ((props?: any) => void) | undefined; |
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.
Is typescript still make us use | undefined
although onPress
is an optional?
(We don't use it in onCancel
and onDone
for example)
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 are looking at the generatedTypes file, this is how it generates the d.ts files apparently.
The source code doesn't have it
Description
Fix callback props typings in components like: TouchableOpacity, Card and Modal.TopBar
Changelog
Fix callback props typings in components like: TouchableOpacity, Card and Modal.TopBar