1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 | 'use strict';
|
10 |
|
11 | var _prodInvariant = require('./reactProdInvariant');
|
12 |
|
13 | var ReactPropTypeLocationNames = require('./ReactPropTypeLocationNames');
|
14 | var ReactPropTypesSecret = require('./ReactPropTypesSecret');
|
15 |
|
16 | var invariant = require('fbjs/lib/invariant');
|
17 | var warning = require('fbjs/lib/warning');
|
18 |
|
19 | var ReactComponentTreeHook;
|
20 |
|
21 | if (typeof process !== 'undefined' && process.env && process.env.NODE_ENV === 'test') {
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 | ReactComponentTreeHook = require('./ReactComponentTreeHook');
|
28 | }
|
29 |
|
30 | var loggedTypeFailures = {};
|
31 |
|
32 |
|
33 |
|
34 |
|
35 |
|
36 |
|
37 |
|
38 |
|
39 |
|
40 |
|
41 |
|
42 |
|
43 |
|
44 | function checkReactTypeSpec(typeSpecs, values, location, componentName, element, debugID) {
|
45 | for (var typeSpecName in typeSpecs) {
|
46 | if (typeSpecs.hasOwnProperty(typeSpecName)) {
|
47 | var error;
|
48 |
|
49 |
|
50 |
|
51 | try {
|
52 |
|
53 |
|
54 | !(typeof typeSpecs[typeSpecName] === 'function') ? process.env.NODE_ENV !== 'production' ? invariant(false, '%s: %s type `%s` is invalid; it must be a function, usually from React.PropTypes.', componentName || 'React class', ReactPropTypeLocationNames[location], typeSpecName) : _prodInvariant('84', componentName || 'React class', ReactPropTypeLocationNames[location], typeSpecName) : void 0;
|
55 | error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret);
|
56 | } catch (ex) {
|
57 | error = ex;
|
58 | }
|
59 | process.env.NODE_ENV !== 'production' ? warning(!error || error instanceof Error, '%s: type specification of %s `%s` is invalid; the type checker ' + 'function must return `null` or an `Error` but returned a %s. ' + 'You may have forgotten to pass an argument to the type checker ' + 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' + 'shape all require an argument).', componentName || 'React class', ReactPropTypeLocationNames[location], typeSpecName, typeof error) : void 0;
|
60 | if (error instanceof Error && !(error.message in loggedTypeFailures)) {
|
61 |
|
62 |
|
63 | loggedTypeFailures[error.message] = true;
|
64 |
|
65 | var componentStackInfo = '';
|
66 |
|
67 | if (process.env.NODE_ENV !== 'production') {
|
68 | if (!ReactComponentTreeHook) {
|
69 | ReactComponentTreeHook = require('./ReactComponentTreeHook');
|
70 | }
|
71 | if (debugID !== null) {
|
72 | componentStackInfo = ReactComponentTreeHook.getStackAddendumByID(debugID);
|
73 | } else if (element !== null) {
|
74 | componentStackInfo = ReactComponentTreeHook.getCurrentStackAddendum(element);
|
75 | }
|
76 | }
|
77 |
|
78 | process.env.NODE_ENV !== 'production' ? warning(false, 'Failed %s type: %s%s', location, error.message, componentStackInfo) : void 0;
|
79 | }
|
80 | }
|
81 | }
|
82 | }
|
83 |
|
84 | module.exports = checkReactTypeSpec; |
\ | No newline at end of file |