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

Make default props optional in type definition #614

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

netmaxt3r
Copy link

Overview

this helps in unnecessary typescript errors while creating a wrapper component

Test Plan

suppose we create a warpper for modal component with app specific default props like below

import OModal, {ModalProps} from "react-native-modal";

export default function Modal(props: ModalProps) {
	return <OModal hideModalContentWhileAnimating={true} {...props} />;
}

you will see typescript error "TS2783: 'hideModalContentWhileAnimating' is specified more than once, so this usage will be overwritten."
when you use component with optional call backs from parent like below this.props.onModalShow is optional

<Modal 
   isVisible={this.state.show}
   onModalShow={this.props.onModalShow}>

you will see typescript error "TS2322: Type '(() => void) | undefined' is not assignable to type '() => void'.   Type 'undefined' is not assignable to type '() => void'."

@netmaxt3r netmaxt3r changed the title Make default props optional in type defenistion Make default props optional in type definition Oct 6, 2021
this helps in unnecessary typescript errors while creating
a wrapper component
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.

None yet

2 participants