From c9cd741aff6acedaedfd2cf96df06a8b46b4826a Mon Sep 17 00:00:00 2001 From: Rohit Sharma Date: Thu, 14 Jan 2021 01:43:30 +0530 Subject: Throw a `TypeError` instead of the generic `Error` (#32585) * Change from Error to TypeError * Convert the `NAME` to upper case to make the consistency in the error message * Update the remaining tests to be stricter Co-authored-by: XhmikosR --- js/src/util/index.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'js/src/util') diff --git a/js/src/util/index.js b/js/src/util/index.js index 9ccad1cbb..22d0a578b 100644 --- a/js/src/util/index.js +++ b/js/src/util/index.js @@ -111,15 +111,14 @@ const typeCheckConfig = (componentName, config, configTypes) => { Object.keys(configTypes).forEach(property => { const expectedTypes = configTypes[property] const value = config[property] - const valueType = value && isElement(value) ? - 'element' : - toType(value) + const valueType = value && isElement(value) ? 'element' : toType(value) if (!new RegExp(expectedTypes).test(valueType)) { - throw new Error( + throw new TypeError( `${componentName.toUpperCase()}: ` + `Option "${property}" provided type "${valueType}" ` + - `but expected type "${expectedTypes}".`) + `but expected type "${expectedTypes}".` + ) } }) } -- cgit v1.2.3