Skip to content
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

Add Symbol prop type #6387

Closed
wants to merge 3 commits into from
Closed

Conversation

RaitoBezarius
Copy link
Contributor

Hi there,

As it seemed that no one took #4917, here is my pull request for it.

Some rationale behind the choice as Symbols are essentially polyfilled / transpiled:

  • If the typeof is Symbol -- native support or Babel plugin, then it is a Symbol.
  • If it behaves like a Symbol (according to Mozilla doc) -- polyfill / no native support, then it is a Symbol.

Is there any case that I could have missed? Let me know if I need to work on it to get it accepted!
Thanks!

@@ -83,6 +83,7 @@ var ReactPropTypes = {
oneOf: createEnumTypeChecker,
oneOfType: createUnionTypeChecker,
shape: createShapeTypeChecker,
symbol: createSymbolTypeChecker(),
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't it be symbol: createSymbolTypeChecker, (without () at the end)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Calling the createSymbolTypeChecker returns the chainable type checker, right?
As you would do something like: React.PropTypes.symbol.isRequired and not React.PropTypes.symbol().isRequired (am I wrong?)

@gaearon
Copy link
Collaborator

gaearon commented Mar 31, 2016

There is #6377 though. Maybe you should collaborate 😉

@RaitoBezarius
Copy link
Contributor Author

@gaearon @puradox Should we continue the PR here? We can backport my commits to its PR or I can backport its commits to my PR. Anyway, I'm very interested in improving the test suite!
If we could test it against the most popular polyfill (es6-promise, core-js, Babel transpilation, etc...), that would be awesome.

@puradox
Copy link
Contributor

puradox commented Mar 31, 2016

@RaitoBezarius We have a bit more conversation over on my PR. You should take a look and we can collaborate together on which approach is best. Take a look at my changes and compare it with yours. From what it looks like, you treated Symbol as a separate data type, whereas I treated it as a primitive.

@RaitoBezarius
Copy link
Contributor Author

@gaearon @puradox Let's mark it as closed and continue over your PR, if it is okay.

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

Successfully merging this pull request may close these issues.

5 participants