-
Notifications
You must be signed in to change notification settings - Fork 49.5k
Closed as not planned
Labels
Status: UnconfirmedA potential issue that we haven't yet confirmed as a bugA potential issue that we haven't yet confirmed as a bug
Description
I need to set a constraint on parent component, so only children of certain type are allowed. Maybe this is intended behavior, but if so how do you set constraint?
React version: 18.2.0
Steps To Reproduce
- Create a component with children property and use generic type React.ReactElement
to constrain what children are allowed to be passed
- Observe that you can still add any child as if React.ReactElement is used
Link to code example: https://codesandbox.io/s/react-typescript-forked-wzkkvl?file=/src/App.tsx
The current behavior
Allows the children of parent to be of any type
The expected behavior
Parent component should be marked with error "Types of property 'children' are incompatible." if other component is passed as child
Metadata
Metadata
Assignees
Labels
Status: UnconfirmedA potential issue that we haven't yet confirmed as a bugA potential issue that we haven't yet confirmed as a bug