eb6a5fa35d9115c4b0516b6367dcb675a74f12ffd974deb634278543886a6199f6a5bf05a41665de65d0df0f926e94ae020bb706b012deb76dbe73fa95bf49 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /**
  2. * Copyright (c) 2013-present, Facebook, Inc.
  3. *
  4. * This source code is licensed under the MIT license found in the
  5. * LICENSE file in the root directory of this source tree.
  6. */
  7. 'use strict';
  8. var ReactPropTypesSecret = require('./lib/ReactPropTypesSecret');
  9. function emptyFunction() {}
  10. function emptyFunctionWithReset() {}
  11. emptyFunctionWithReset.resetWarningCache = emptyFunction;
  12. module.exports = function() {
  13. function shim(props, propName, componentName, location, propFullName, secret) {
  14. if (secret === ReactPropTypesSecret) {
  15. // It is still safe when called from React.
  16. return;
  17. }
  18. var err = new Error(
  19. 'Calling PropTypes validators directly is not supported by the `prop-types` package. ' +
  20. 'Use PropTypes.checkPropTypes() to call them. ' +
  21. 'Read more at http://fb.me/use-check-prop-types'
  22. );
  23. err.name = 'Invariant Violation';
  24. throw err;
  25. };
  26. shim.isRequired = shim;
  27. function getShim() {
  28. return shim;
  29. };
  30. // Important!
  31. // Keep this list in sync with production version in `./factoryWithTypeCheckers.js`.
  32. var ReactPropTypes = {
  33. array: shim,
  34. bigint: shim,
  35. bool: shim,
  36. func: shim,
  37. number: shim,
  38. object: shim,
  39. string: shim,
  40. symbol: shim,
  41. any: shim,
  42. arrayOf: getShim,
  43. element: shim,
  44. elementType: shim,
  45. instanceOf: getShim,
  46. node: shim,
  47. objectOf: getShim,
  48. oneOf: getShim,
  49. oneOfType: getShim,
  50. shape: getShim,
  51. exact: getShim,
  52. checkPropTypes: emptyFunctionWithReset,
  53. resetWarningCache: emptyFunction
  54. };
  55. ReactPropTypes.PropTypes = ReactPropTypes;
  56. return ReactPropTypes;
  57. };