-
Notifications
You must be signed in to change notification settings - Fork 1.4k
PropTypes.exact for all props has errors #263
Comments
@ljharb You almost gave me a heart attack there (until I saw that my changes hadn't been published to npm yet) 😄 Is that a valid propTypes declaration though? Can the top-level propTypes be a validator function instead of an object literal? |
@asbjornh no, but |
@jaydenseric can you provide the exact component code for |
@ljharb Are you sure about that? Both the following output
I can reproduce @jaydenseric's case like this (it outputs the same error message):
I can't see that |
Oh, actually, you only need this in order to reproduce:
I'm guessing it's because the returned function has an
|
There’s no docs in the readme, so it’s possible this implementation of exact is just a form of “shape” - as opposed to https://npmjs.com/prop-types-exact which works as you expect. |
because prop-types/factoryWithTypeCheckers.js Line 223 in e32c490
and the |
I ran into this as well and so had a look at it and I guess making
I am not sure if that breaks other things though. |
Seems like perhaps |
Any updates? This makes |
The error that OP describes is not unique to
The documentation doesn't state this directly, but I think Assuming that this isn't supported, what you're seeing is undefined behavior caused by incorrect use of the API. As far as I can tell, the "bug" here is that incorrect use fo the API results in a cryptic error message which should be improved. I guess using |
The entire point of PropTypes.exact is to use it as the .propTypes value, so that the entire props object is checked for extra props. |
Using
PropTypes.exact
for all the props causes errors.Something like this:
Errors strangely like this:
The text was updated successfully, but these errors were encountered: