Skip to content
This repository has been archived by the owner on Sep 1, 2024. It is now read-only.

.set and .setOf #191

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

.set and .setOf #191

wants to merge 1 commit into from

Conversation

Pimm
Copy link

@Pimm Pimm commented Jun 5, 2018

An implementation for .set and .setOf. Please hit me with your feedback, thoughts, and ideas.

I can implement .map and .mapOf in this PR as well.

@ljharb mentioned that instanceof Set does not work everywhere. Perhaps that has to be fixed.

Copy link
Contributor

@ljharb ljharb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about Map?

function createSetTypeChecker(expectedType) {
function validate(props, propName, componentName, location, propFullName, secret) {
var propValue = props[propName];
if (!(propValue instanceof Set)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indeed, this should module-level-cache the getter for Set.prototype.size, call-bind it, and invoke it here.

return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside setOf.');
}
var propValue = props[propName];
if (!(propValue instanceof Set)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also here

@@ -505,6 +553,8 @@ module.exports = function(isValidElement, throwOnDirectAccess) {
return 'date';
} else if (propValue instanceof RegExp) {
return 'regexp';
} else if (propValue instanceof Set) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and here

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants