Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

>leading to people adding their own children definitions to their props interfaces

IMO this is a feature not a bug. Type definitions aren't just for the compiler, they're also for the developer. Being able to see at a glance which components expect children and which don't is really valuable. Not to mention that there are situations where I want to restrict what kinds of children can be passed in (think render-props, or named slot projection patterns).

In other words, just because React supports an implicit definition of what a "child" can be doesn't mean that my specific component supports all of those same possibilities.



I see your point, and agree under the condition that I trust everyone contributing to the codebase knows it. But, in reality, they don’t. I’d rather have the children type available but unused most of the time than one-off type definitions of children.

Maybe for you my own projects I’ll employ your approach, because I agree from the fundamentals side of it




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: