-
Notifications
You must be signed in to change notification settings - Fork 346
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[IMP] types: correctly support
Function
type for props-validation
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 the `BaseType` union, which allows declaring that a component expects a function as a prop. Closes #1448
- Loading branch information
1 parent
941190d
commit e94428a
Showing
4 changed files
with
5 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ type BaseType = | |
| typeof Date | ||
| typeof Object | ||
| typeof Array | ||
| typeof Function | ||
| true | ||
| "*"; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters