-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
prop-types: children and React.VFC #2913
Comments
That seems very wrong and strange to me; “void” refers to the return type generally, but “takes children” has no bearing on “renders children”. Can you confirm? |
Yes, the naming is poor, but the semantics is truly about taking children, and not about the "void". |
Who decided this type name? Can you provide a link? |
Here is the type: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/f4f453b018d0d512cde50efb6db35fd3f8a001ab/types/react/index.d.ts#L551 UPD: just wanted to add that, in my opinion, the name is not perfect, however, from the code it looks like it does exactly this - eliminates the children from the props. So, I propose that we don't spend time on the discussion of the type name (it is a confusing one), and focus on thinking about how we could make use of it - because, it seems like there is finally a way to make it right. To address the name, we can create an issue/PR to the https://github.com/DefinitelyTyped/DefinitelyTyped. I'm sure it'll be easy to patch up another name if it's renamed at DefinitelyTyped after the implementation is there. |
Thanks. While it is quite a terrible name, it makes sense that prop-types should be able to respect it. |
@ljharb I could give this a shot. From what I understand is that the plugin needs to communicate the absence of children prop at the TypeScript level: |
I'm not sure where the best place to change it is - we have shared propType detection code, and it might be useful to detect this there so other propType rules can check it. However, it may instead be better to only check it in the prop-types rule. |
@ljharb I guess the |
What indicates it would be deprecated? |
@ljharb Yeah your right there is no idication I guess I just read it somewehre |
@ljharb @sladyn98 ran into it here: https://basarat.gitbook.io/typescript/tsx/react#void-function-components
|
In that case we’d need to know which version of the types we were looking at, which makes this a bit more complex :-/ |
Which class replaces |
I like that they’ll delete If that’s the intention,
I much prefer this upgrade path:
|
There is now a way to properly communicate the absence of the
children
prop at the TypeScript level:React.VFC
(vsReact.FC
).React.VFC
akaReact.VoidFunctionComponent
does not allowchildren
prop, theprop-types
rule should derive the presence/absence ofchildren
from the underlying TypeScript types (when used with TypeScript).Related: #7.
The text was updated successfully, but these errors were encountered: