mirror of
https://github.com/idanoo/GoScrobble.git
synced 2024-11-23 00:45:16 +00:00
23 lines
870 B
JavaScript
23 lines
870 B
JavaScript
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
// This module is based on https://github.com/airbnb/prop-types-exact repository.
|
|
// However, in order to reduce the number of dependencies and to remove some extra safe checks
|
|
// the module was forked.
|
|
// Only exported for test purposes.
|
|
export const specialProperty = 'exact-prop: \u200b';
|
|
export default function exactProp(propTypes) {
|
|
if (process.env.NODE_ENV === 'production') {
|
|
return propTypes;
|
|
}
|
|
|
|
return _extends({}, propTypes, {
|
|
[specialProperty]: props => {
|
|
const unsupportedProps = Object.keys(props).filter(prop => !propTypes.hasOwnProperty(prop));
|
|
|
|
if (unsupportedProps.length > 0) {
|
|
return new Error(`The following props are not supported: ${unsupportedProps.map(prop => `\`${prop}\``).join(', ')}. Please remove them.`);
|
|
}
|
|
|
|
return null;
|
|
}
|
|
});
|
|
} |