Skip to content

[@types/react] Alternative FunctionComponent without children #34237

@Dremora

Description

@Dremora

Authors: @VincentLanglet

A change introduced recently means that every component can now accept children. This is simply not a valid assumption, and it breaks the principle of least astonishment. When creating a component, I expect to have to provide all props. If the component (e.g. an icon) expects no props, I want to simply provide {} as the type argument and expect any attempt to pass children (or any other props) to the component to result in an error. Moreover, children can be of a narrower type (e.g. our Button component, as per design system, only expects a string, trying to pass anything else should result in an error).

Please consider removing PropsWithChildren from FunctionComponent. Additionally, we could have a FunctionComponentWithChildren that satisfies the current use case.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions