[IMP] types: correctly support Function
type for props-validation
#1560
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Previously, having a Function as a type in the static props description of a component would only work if the component was not the root component, as the static props description on Component was "any", whereas the static props description on ComponentConstructor was "Schema". This meant that static props description on non-root components was not type-checked, and on root components it was type-checked only on the mount call.
This commit makes it so that static type description is of type "Schema" on Component, now causing static props description to be type-checked, and adds
typeof Function
to theBaseType
union, which allows declaring that a component expects a function as a prop.Closes #1448