Closed ivmarkov closed 6 years ago
99% of people wont really care about the implementation details of ReactElement. I am ok changing it. However, it is going to be a breaking change. My plan is to release react 16 support first. Then I will do one release with all the breaking changes. That way people don't have to keep migrating their codebase.
Given that I am in the middle of a big refactor to support React 16.2 and Elemental, I committed this change. I also removed DOMElement as it just subclassed ReactElement and added no further value.
Currently, ReactElement has the following signature:
That's all nice and dandy, except that every time we create or pass around ReactElement instances, we find ourselves always using the
ReactElement<?, ?>
signature. In other words we don't care a single bit what the actual types of the Props class and the component are. Not to mention that the T parameter is unbound, and cannot be make bound, becauseComponentConstructorFn
,StatelessComponent
, andComponent
all have no single parent and cannot have one.I actually have my own personal contribution in the above (remember?), but perhaps it is not too late to consider alternatives. How about this:
Yes. We lose a bit of type safety for the rare case when somebody would indeed have to be sure what the exact type of the props and component type is, but how frequent are these cases?