-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Closed
Description
Consider the following example:
type Component1Props = { ... }
const Component1: React.SFC<Component1Props> = props => { ... }
type Component2Props = { ... }
const Component2: React.SFC<Component2Props> = props => { ... }
const Component3: React.SFC<???> = props => {
// some prop from Component1Props
if(props.prop1) {
return <Component1 {...props} />
}
// some prop from Component2Props
if(props.prop2) {
return <Component2 {...props} />
}
}
Ideally I want typechecker to handle two things:
- It's required to pass either prop1 or prop2, but not both of them
- If prop1 is passed then props are of type Component1Props and if prop2 is passed then props are of type Component2Props
P. S. I'm completely new to TypeScript and I'm not sure that it's even possible)
garethbjohnson
Metadata
Metadata
Assignees
Labels
No labels