From 14478f6701520390f00810d574892d0825e5256c Mon Sep 17 00:00:00 2001 From: Martin Kralik Date: Wed, 9 Dec 2015 04:04:23 -0800 Subject: [PATCH] better error message for `propTypes` check Summary: When you did a typo in declaring a prop type (like using `boolean` insteal of `bool`) you'd got a bit misleading error message: {F27113768} The truth is that the prop type is defined, but not correctly. So I've changed the message in this case to be more accurate: {F27113627} public Reviewed By: sahrens Differential Revision: D2729340 fb-gh-sync-id: dd12c10a4f3a1c9825293f86481a082908127a76 --- Libraries/ReactIOS/verifyPropTypes.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/Libraries/ReactIOS/verifyPropTypes.js b/Libraries/ReactIOS/verifyPropTypes.js index a7ccd210b6b134..1974716ba26062 100644 --- a/Libraries/ReactIOS/verifyPropTypes.js +++ b/Libraries/ReactIOS/verifyPropTypes.js @@ -41,11 +41,16 @@ function verifyPropTypes( if (!componentInterface.propTypes[prop] && !ReactNativeStyleAttributes[prop] && (!nativePropsToIgnore || !nativePropsToIgnore[prop])) { - throw new Error( - '`' + componentName + '` has no propType for native prop `' + + var message; + if (componentInterface.propTypes.hasOwnProperty(prop)) { + message = '`' + componentName + '` has incorrectly defined propType for native prop `' + + viewConfig.uiViewClassName + '.' + prop + '` of native type `' + nativeProps[prop]; + } else { + message = '`' + componentName + '` has no propType for native prop `' + viewConfig.uiViewClassName + '.' + prop + '` of native type `' + - nativeProps[prop] + '`' - ); + nativeProps[prop] + '`'; + }; + throw new Error(message); } } }